tomlrt
A format-preserving TOML reader and writer for Python.
What it is and what it does
tomlrt is a TOML parser and writer that treats formatting as data rather than noise. When you load a TOML file, edit it, and dump it back, every byte you didn't touch stays exactly as it was—comments, blank lines, indentation, quote style, and number formatting all round-trip intact. This makes it ideal for tools that need to modify configuration files programmatically while preserving human-written structure and intent.
The package supports TOML 1.1 and exposes both a file-based API (load/dump) and a programmatic one (Document class for building documents from scratch). It depends only on typing-extensions, keeping the install lightweight. The implementation is pure Python, distributed as a wheel, and requires Python 3.10 or later.
Use it for:
- Updating version strings or dependencies in pyproject.toml while keeping existing comments and formatting intact.
- Building configuration management tools that edit TOML files without destroying developer-written structure.
- Programmatically modifying application config files where preserving layout matters for readability or version control diffs.
- Creating TOML editors or linters that need to round-trip documents without lossy parsing.
- Generating new TOML documents from scratch using the Document API when format preservation isn't required.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Reads and writes TOML files while preserving formatting, comments, whitespace, and string styles exactly as they appear in the original document.
Yes. tomlrt solves a real problem—standard TOML parsers discard formatting, making them unsuitable for editing user-facing config files. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and installs with minimal friction. Use it whenever you need to read, modify, and write TOML while respecting the original document's structure.
Install
tomlrt on PyPI
pip
pip install tomlrtuv
uv add tomlrtpoetry
poetry add tomlrtInstalling tomlrt
Before you install
Low friction: pure Python wheel, single lightweight dependency (typing-extensions), active maintenance with a release 1 day old.
License in practice
MIT license permits unrestricted use, modification, and distribution in both open-source and commercial projects.
Quickstart
import tomlrt
with open("pyproject.toml", "rb") as f:
doc = tomlrt.load(f)
doc["project"]["version"] = "0.2.0"
print(tomlrt.dumps(doc))
Requires Python 3.10 or later.
Verify before relying
- Whether round-trip fidelity holds for all TOML 1.1 edge cases (inline tables, nested structures, escape sequences).
- Performance characteristics on large configuration files (parsing speed, memory usage).
- Behavior when modifying deeply nested structures or adding new keys not in the original document.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing-extensions |
| Maintenance | actively maintained — 1 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 93,055/month — #13,403 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tomlrt-2.2.2-py3-none-any.whl
Keywords: config, configuration, format-preserving, pyproject, round-trip, toml, toml-parser, toml-writer, tomlrt
Tags
More Markup packages
PyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
markdown-it-pyA Python markdown parser that converts markdown…
permissive · top 100 on PyPI
beautifulsoup4Beautiful Soup parses HTML and XML documents…
permissive · top 100 on PyPI
et-xmlfileet_xmlfile writes large XML files with minimal…
permissive · top 1,000 on PyPI
tomlkitParses and edits TOML files while preserving…
permissive · top 1,000 on PyPI
docstring-parserParses Python docstrings in ReST, Google,…
permissive · top 1,000 on PyPI
tomli-wTomli-W serializes Python dictionaries to TOML…
permissive · top 1,000 on PyPI
pytomlParses and writes TOML configuration files with…
permissive · top 15,000 on PyPI
edn-formatReads and writes EDN (Extensible Data Notation)…
permissive · top 5,000 on PyPI
pyproject-fmtFormats pyproject.toml files with consistent,…
permissive · top 5,000 on PyPI
toml-cliCommand-line tool for reading, writing, and…
permissive · top 15,000 on PyPI
tox-toml-fmtFormats tox.toml files with consistent style…
permissive · top 15,000 on PyPI
toml-sortCommand-line utility and Python library to sort…
permissive · top 15,000 on PyPI
ggufReads and writes binary files in the GGUF (GGML…
permissive · top 5,000 on PyPI
tomliTomli parses TOML configuration files and…
permissive · top 1,000 on PyPI