pytoml
A strict, specs-conforming TOML 0.4.0 parser and writer for Python.
Repository Health
Technical Analysis
pytoml is a Python library for reading and writing TOML configuration files, aiming to be a strict and specs-conforming implementation of TOML version 0.4.0. It exposes an interface modeled directly on the standard library’s json module, with load/loads for parsing and dump/dumps for serialization.
The library parses TOML from bytes or unicode into ordinary Python dictionaries and serializes dictionaries back into TOML text. Note that pytoml is deprecated and no longer actively maintained; its maintainers recommend newer TOML packages for new projects, but it remains widely downloaded and useful for understanding or maintaining legacy tooling.
What You Get
- A json-style API with load, loads, dump, and dumps functions
- A strict, specs-conforming parser for TOML version 0.4.0
- TOML serialization from ordinary Python dictionaries
- Support for both bytes (UTF-8) and unicode input
Common Use Cases
- Reading TOML configuration files into Python dictionaries
- Writing Python data structures out as TOML text
- Maintaining legacy tools and scripts that already depend on pytoml
Under The Hood
Architecture - The package is small and cleanly separated: parser.py implements the TOML tokenizer and recursive-descent parser producing Python dictionaries, writer.py serializes dictionaries back to TOML text, core.py defines the shared exception types, and utils.py holds helpers. The public __init__.py exposes the json-style load, loads, dump, and dumps entry points.
Tech Stack - Pure Python with no runtime dependencies, packaged with a classic setup.py/setup.cfg and tested across interpreters via tox. It supports Python 2.7 and 3.5+, reflecting its 2010s origins.
Code Quality - The repository includes a test/ suite driven by the shared toml-test compliance submodule, which exercises the parser against the official TOML conformance cases. The code is compact and readable, though it is frozen at the TOML 0.4.0 spec and is explicitly deprecated, so it does not cover newer TOML features.
API Design - Developer experience is a strength: by deliberately mirroring the standard json module, the API requires almost no learning for any Python developer. The main caveat is that its deprecation and 0.4.0-only support mean it should not be chosen for new projects.