talira

TOML Kit

Style-preserving TOML library for Python that keeps comments and layout

open sourceMITfree

TOML Kit (tomlkit) is a TOML 1.1.0-compliant library for Python whose parser keeps every comment, indentation, whitespace and element order, so a program can edit a TOML file such as pyproject.toml and write it back without disturbing its layout. It can also build new TOML documents from scratch. It's from the python-poetry organisation.

Problems it solves

  • update a value in pyproject.toml from a script without losing the comments
  • edit a TOML config file in Python and keep its formatting
  • generate a TOML file from Python

Features

  • TOML 1.1.0 compliant
  • parser that preserves comments, indentation, whitespace and element order
  • edit a document through its API and write it back with the layout intact
  • create new TOML documents from scratch

Limitations

  • A sub-table that extends an array of tables out of order is moved into the array's last element when the document is written back; the data is kept but its placement changes.1

Alternatives

The same job

These do what TOML Kit does.

  1. Tomli Small, fast TOML 1.1.0 parser for Python

Compare TOML Kit with the top 3