tomlkit
Style preserving TOML library
Decision gist · record as of 2026-08-14
Yes. Tomlkit is a solid choice for any Python project that needs to read or edit TOML files while preserving formatting. It has no dependencies, is actively maintained, supports current Python versions, carries no known vulnerabilities, and is licensed permissively under MIT. Install it if you're building tools that touch TOML files and user readability of the source matters.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Low friction: pure Python wheel with no runtime dependencies.
- Actively maintained with a release 28 days ago and recent commits.
License · maintenance · safety
MIT (permissive) — MIT license (permissive): you can use, modify, and distribute tomlkit freely in commercial and private projects with minimal restrictions.
last release 2026-07-17 (28 days) · last repo commit 2026-08-10 · 842 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 338,023,114 downloads/mo, #124 on PyPI
Alternatives
Verify before relying
pip install tomlkit
import tomlkit
doc = tomlkit.parse(open('config.toml').read())
doc['key'] = 'value'
print(tomlkit.dumps(doc))- Whether the documented limitation (sub-table reordering in array-of-tables contexts) affects your use case.
- Performance characteristics when handling very large TOML documents.
What it is and what it does
Tomlkit is a TOML 1.1.0-compliant parser and serializer that treats TOML documents as editable objects while preserving all formatting details—comments, indentation, whitespace, and element order. Unlike standard TOML parsers that discard formatting on read, tomlkit reconstructs the original layout when you serialize the document back, making it suitable for tools that need to modify configuration files without losing user-added structure or notes.
It has no runtime dependencies and works across Python 3.9 through 3.14. You can parse existing TOML files, modify their contents programmatically, and write them back with formatting intact, or create new TOML documents from scratch using provided helpers. The library is actively maintained and widely used in the Python ecosystem.
Use it for
- Edit pyproject.toml or other config files programmatically while preserving user comments and formatting.
- Build tools that read and modify TOML configuration without losing manual edits or structure.
- Round-trip TOML documents through Python code without normalizing or reformatting them.
- Create TOML documents from scratch with an intuitive API for setting values and sections.
- Parse TOML in applications where preserving the original document layout is important for user experience.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Tomlkit is a solid choice for any Python project that needs to read or edit TOML files while preserving formatting. It has no dependencies, is actively maintained, supports current Python versions, carries no known vulnerabilities, and is licensed permissively under MIT. Install it if you're building tools that touch TOML files and user readability of the source matters.
Install
tomlkit on PyPI
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained with a release 28 days ago and recent commits. Supports Python 3.9 through 3.14.
Requires Python 3.9 or later.
License in practice
MIT license (permissive): you can use, modify, and distribute tomlkit freely in commercial and private projects with minimal restrictions.
Quickstart
pip install tomlkit
import tomlkit
doc = tomlkit.parse(open('config.toml').read())
doc['key'] = 'value'
print(tomlkit.dumps(doc))
Verify before relying
- Whether the documented limitation (sub-table reordering in array-of-tables contexts) affects your use case.
- Performance characteristics when handling very large TOML documents.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 28 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 338,023,114 / month, #124 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9 |
Evidence: tomlkit-0.15.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “TOML parser preserve formatting”
- tomlkitParses and edits TOML files while preserving formatting, comments,…
- tree-sitter-tomlProvides a tree-sitter parser grammar for TOML files, enabling…
- tomlrtReads and writes TOML files while preserving formatting, comments,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Markup packages
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
A Python markdown parser that converts markdown to HTML following the CommonMark specification, with support for plugins and custom syntax rules.
Install it if you need reliable markdown-to-HTML conversion.
Beautiful Soup parses HTML and XML documents into a navigable tree, providing Pythonic methods to search, iterate, and modify the parsed content.
Install it if you need to parse or extract data from markup documents.
et_xmlfile writes large XML files with minimal memory overhead by serializing elements to disk as they are created, rather than holding the entire tree in memory.
Install it if incremental XML writing fits your use case; skip it if your XML documents are small or you already use lxml.
Parses Python docstrings in ReST, Google, Numpydoc, and Epydoc formats, extracting structured information like descriptions, parameters, return types, and exceptions.
Install it if you need to programmatically read and extract structured data from Python docstrings.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
See also tomlrt · tomli · codemod-yaml · tox-toml-fmt · toml-sort · pytoml · pyproject-fmt · commented-configparser · untokenize · lkml