python-tomli
Port variant v14
Summary Lil' TOML parser (3.14)
Package version 2.5.0
Homepage https://github.com/hukkin/tomli
Keywords python
Maintainer Python Automaton
License Not yet specified
Other variants v15
Ravenports Buildsheet | History
Ravensource Port Directory | History
Last modified 13 NOV 2026, 13:25:52 UTC
Port created 19 JUL 2021, 04:13:17 UTC
Subpackage Descriptions
single [Build Status] [PyPI version] # Tomli > A lil' TOML parser **Table of Contents** *generated with [mdformat-toc]* - [Intro] - [Installation] - [Usage] - [Parse a TOML string] - [Parse a TOML file] - [Handle invalid TOML] - [Construct `decimal.Decimal`s from TOML floats] - [Building a `tomli`/`tomllib` compatibility layer] - [FAQ] - [Why this parser?] - [Is comment preserving round-trip parsing supported?] - [Is there a `dumps`, `write` or `encode` function?] - [How do TOML types map into Python types?] - [Performance] - [Mypyc generated wheel] - [Pure Python] ## Intro Tomli is a Python library for parsing [TOML]. Version 2.4.0 and later are compatible with [TOML v1.1.0]. Older versions are [TOML v1.0.0] compatible. A version of Tomli, the `tomllib` module, was added to the standard library in Python 3.11 via [PEP 680]. Tomli provides a TOML v1.1.0 compatible backport for Pythons older than 3.15. On the other hand, installing `tomli<2.4` allows TOML v1.0.0 parsing on Python 3.15+. Tomli uses [mypyc] to generate binary wheels for most of the widely used platforms, so some may prefer it over `tomllib` for improved performance. Pure Python wheels are available on any platform and should perform the same as `tomllib`. ## Installation `bash pip install tomli ` ## Usage ### Parse a TOML string ```python import tomli toml_str = """ [[players]] name = "Lehtinen" number = 26 [[players]] name = "Numminen" number = 27 """ toml_dict = tomli.loads(toml_str) assert toml_dict == { "players": [{"name": "Lehtinen", "number": 26}, {"name": "Numminen", "number": 27}] } ``` ### Parse a TOML file ```python import tomli with open("path_to_file/conf.toml", "rb") as f: toml_dict = tomli.load(f) ``` The file must be opened in binary mode (with the `"rb"` flag). Binary mode will enforce decoding the file as UTF-8 with universal newlines disabled, both of which are required to correctly parse TOML. ### Handle invalid TOML ```python import tomli try:
Configuration Switches (platform-specific settings discarded)
PY314 ON Build using Python 3.14 PY315 OFF Build using Python 3.15
Package Dependencies by Type
Build (only) python314:dev:std
python-pip:single:v14
autoselect-python:single:std
Build and Runtime python314:primary:std
Download groups
main mirror://PYPIWHL/60/3f/3e3f8fd0919249b0200c80fbc4f9a1e70be19f9883da71dfb7f8b9ab8aca
Distribution File Information
32a7b79ac57a2e83670ce329ccf675798bc5a2094783a63676866b70503f2e2b 14765 python-src/tomli-2.5.0-py3-none-any.whl
Ports that require python-tomli:v14
python-maturin:v14 Build and publish python rust packages (3.14)
python-nab-python:v14 Nab package index provider (3.14)