tomli
A lil' TOML parser
This package has a good security score with no known vulnerabilities.
Community Reviews
Rock-solid TOML parser with excellent security posture
From a security standpoint, tomli excels. It has zero dependencies, eliminating supply chain risk entirely. The codebase is small and auditable. Error messages are informative without leaking sensitive data - they point to line numbers and syntax issues without echoing potentially sensitive configuration values. Input validation is strict by design since it implements the TOML spec faithfully, rejecting malformed input rather than trying to be clever.
The library became part of Python 3.11+ stdlib as `tomllib`, which speaks to its quality. For Python 3.10 and earlier, tomli is the backport you want. No crypto concerns since it's just a parser, no network operations, no file path traversal issues - it operates only on the data you explicitly provide.
Best for: Projects needing to parse TOML configuration files with strict security requirements and minimal dependencies.
Avoid if: You're on Python 3.11+ where the stdlib tomllib is already available, or you need bidirectional TOML read/write in one package.
Rock-solid TOML parser with excellent security properties
The API is refreshingly simple: tomli.load() for file objects and tomli.loads() for strings. It strictly follows the TOML spec, which means you get predictable parsing behavior. Input validation is robust - I've thrown various malformed configs at it during testing and it consistently fails safely with clear TOMLDecodeError exceptions that pinpoint the issue without exposing system internals.
The library is now part of Python 3.11+ as tomllib in the standard library, which speaks to its quality. For projects supporting older Python versions, tomli remains the go-to choice. No authentication/authorization concerns since it's purely a parser, and no crypto/TLS since it operates on local files only.
Best for: Parsing TOML configuration files in security-conscious applications on Python <3.11.
Avoid if: You're on Python 3.11+ (use stdlib tomllib) or need to write TOML files (use tomli-w additionally).
Minimal, secure TOML parser that just works
From a security perspective, tomli handles malformed input gracefully with clear TOMLDecodeError exceptions that don't leak file paths or internal state. Error messages pinpoint line/column numbers without exposing system details. The parser has excellent input validation and I've never seen it crash on malicious input—it just raises appropriate exceptions. Since it's pure Python with no C extensions or crypto, the attack surface is minimal.
The library follows secure-by-default principles: strict TOML 1.0.0 spec compliance means no legacy quirks or permissive parsing that could lead to misconfigurations. It became part of Python 3.11+ stdlib as `tomllib`, which speaks to its code quality. For Python <3.11 projects, tomli is the standard choice.
Best for: Projects on Python <3.11 needing secure, dependency-free TOML parsing for configuration files.
Avoid if: You need TOML writing capabilities or are already on Python 3.11+ where tomllib is built-in.
Sign in to write a review
Sign In