Comparison of Python TOML parser libraries

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • Scout APM - Less time debugging, more time building
  • SonarLint - Deliver Cleaner and Safer Code - Right in Your IDE of Choice!
  • SaaSHub - Software Alternatives and Reviews
  • pypyr automation task runner

    pypyr task-runner cli & api for automation pipelines. Automate anything by combining commands, different scripts in different languages & applications into one pipeline process.

    The pypyr automation pipeline task-runner open-source project recently added TOML parsing & writing functionality as a core feature. To this end, I researched the available free & open-source Python TOML parser libraries to figure out which option to use.

  • Poetry

    Python dependency management and packaging made easy.

    Of the available options, only tomlkit supports style-preserving roundtrip parsing. Furthermore, tomlkit was created for the express purpose of handling TOML parsing for the poetry tool. As this is one of the 2 most popular new PEP517 & PEP518 Python build systems there is some comfort to be had in the wide adoption of a very actively used tool that means a greater likelihood of continued maintenance & support, and specifically that pyproject.toml files should parse without surprises.

  • Scout APM

    Less time debugging, more time building. Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.

  • tomli

    A lil' TOML parser

    tomli Relatively fast read-only parsing. Companion library tomli-w for writing.

  • tomlkit

    Style-preserving TOML library for Python

  • tomlplusplus

    Header-only TOML config file parser and serializer for C++17.

    Python wrapper for the toml++ C++ library.

  • toml

    Python lib for TOML (by uiri)

    toml This was initially vendored in pip itself to deal with pyproject.toml. Even so pip has since moved to tomli.

  • pytoml

    A TOML-0.4.0 parser/writer for Python.

    pytoml Abandoned by the creator for eminently sensible reasons (interesting read too... https://github.com/avakar/pytoml/issues/15) But let's not get into an argument over whether a shiny new fashion in config formats is in fact doing anything better than the previous fashions in config management...

  • SonarLint

    Deliver Cleaner and Safer Code - Right in Your IDE of Choice!. SonarLint is a free and open source IDE extension that identifies and catches bugs and vulnerabilities as you code, directly in the IDE. Install from your favorite IDE marketplace today.

  • qtoml

    Another Python TOML encoder/decoder

    qtoml Still on TOML v0.5.0.

  • pytomlpp

    A python wrapper for tomlplusplus

    pytomlpp Python wrapper for the toml++ C++ library.

  • rtoml

    A better TOML library for python implemented in rust.

    rtoml Python wrapper for fast parsing written in Rust.

  • toml

    Tom's Obvious, Minimal Language

    TOMLKit only lists itself as 1.0.0rc1 compliant. Looking at the TOML spec release history delta of rc1 vs v1, it only looks like clarifications & administrative/documentation updates -there doesn't seem to be anything notable missing or functionally different in rc1 as opposed to v1. It's not impossible that I missed something, though - but given TOMLKit's wide usage via poetry, I would expect obvious out-of-date spec handling to have been noticed by someone somewhere, and I see none such in the issues list.

  • pip

    The Python package installer

    Even pip itself has moved from vendoring toml to tomli. This exodus from toml to tomli includes the very prominent:

  • typeshed

    Collection of library stubs for Python, with static types

    typeshed

  • black

    The uncompromising Python code formatter

    black

  • mypy

    Optional static typing for Python

    mypy

  • coveragepy

    The code coverage tool for Python

    coverage

  • flit

    Simplified packaging of Python modules

    flit

  • tomli-w

    A lil' TOML writer (counterpart to https://github.com/hukkin/tomli)

    tomli, then, seems to be where the Python community in general is coalescing for a "standard" TOML parser. tomli is read-only. For write functionality there is the companion library tomli-w.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts