rtoml: A TOML library for python implemented in rust. · Pythie
rtoml
A TOML library for python implemented in rust.
Why Use rtoml
Correctness: rtoml is based on the widely used and very stable toml
rust crate, it passes all the standard TOML tests for TOML 1.1 as well as
having 100% coverage on python code. Other TOML libraries for python I tried all failed to parse some valid TOML.
Performance: see github.com/pwwang/toml-bench -
rtoml is the fastest Python TOML libraries at the time of writing.
None-value handling: rtoml has flexible support for None values, instead of simply ignoring them.
Install
Requires python>=3.10, binaries are available from PyPI for Linux, macOS and Windows,
see here .
pip install rtoml
If no binary is available on pypi for you system configuration; you'll need rust stable
installed before you can install rtoml.
Usage
load
def load(toml: str | Path | TextIO, *, none_value: str | None = None) -> Dict[str, Any]: ...
Parse TOML via a string or file and return a python dictionary.
toml: a str, Path or file object from open().
: controlling which value in is loaded as in python. By default, is , which means nothing is loaded as
none_value
toml
None
none_value
None
None
loads def loads(toml: str, *, none_value: str | None = None) -> Dict[str, Any]: ...
Parse a TOML string and return a python dictionary. (provided to match the interface of json and similar libraries)
toml: a str containing TOML.
none_value: controlling which value in toml is loaded as None in python. By default, none_value is None, which means nothing is loaded as None
dumps def dumps(obj: Any, *, pretty: bool = False, none_value: str | None = "null") -> str: ...
Serialize a python object to TOML.
obj: a python object to be serialized.
pretty: if True the output has a more "pretty" format.
none_value: controlling how None values in obj are serialized. none_value=None means None values are ignored.
dump def dump(
obj: Any, file: Path | TextIO, *, pretty: bool = False, none_value: str | None = "null"
) -> int: ...
Serialize a python object to TOML and write it to a file.
obj: a python object to be serialized.
file: a Path or file object from open().
pretty: if True the output has a more "pretty" format.
none_value: controlling how None values in obj are serialized. none_value=None means None values are ignored.
Examples from datetime import datetime, timezone, timedelta
import rtoml
obj = {
'title': 'TOML Example',
'owner': {
'dob': datetime(1979, 5, 27, 7, 32, tzinfo=timezone(timedelta(hours=-8))),
'name': 'Tom Preston-Werner',
},
'database': {
'connection_max': 5000,
'enabled': True,
'ports': [8001, 8001, 8002],
'server': '192.168.1.1',
},
}
loaded_obj = rtoml.load("""\
# This is a TOML document.
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # First class dates
[database]
server = "192.168.1.1"
ports = [8001, 8001, 8002]
connection_max = 5000
enabled = true
""")
assert loaded_obj == obj
assert rtoml.dumps(obj) == """\
title = "TOML Example"
[owner]
dob = 1979-05-27T07:32:00-08:00
name = "Tom Preston-Werner"
[database]
connection_max = 5000
enabled = true
server = "192.168.1.1"
ports = [8001, 8001, 8002]
"""
An example of None-value handling:
obj = {
'a': None,
'b': 1,
'c': [1, 2, None, 3],
}
# Ignore None values
assert rtoml.dumps(obj, none_value=None) == """\
b = 1
c = [1, 2, 3]
"""
# Serialize None values as '@None'
assert rtoml.dumps(obj, none_value='@None') == """\
a = "@None"
b = 1
c = [1, 2, "@None", 3]
"""
# Deserialize '@None' back to None
assert rtoml.load("""\
a = "@None"
b = 1
c = [1, 2, "@None", 3]
""", none_value='@None') == obj
Popularity
Downloads, last 7 days 594K+76%
Stars, last 7 days –
Direct dependents 79
All dependents 164 48
Fair
Maintenance, out of 100
Recent release
last release 48 days ago
Commit activity
1/26 weeks with commits
Release cadence
1 releases in 12 months
Issues & PRs handled
84% closed in the past year
Contributor spread
15 authors in last 100 commits
Releases
Latest 0.14.0
Released Oct 12, 2026
Releases, 12 months 1
First release Jan 9, 2020 Compatibility
Requires Python >=3.10
Tested on 3.10 · 3.11 · 3.12 · 3.13 · 3.14 · 3.15
License MIT (Permissive) AlternativesUse instead of rtoml: tools that do the same job, closest first.
Compare with toml → Compare with toml-rs → Compare with pytoml → Compare all 4 →
toml 0.10.2 Inactive Pythie’s Index: 18Python Library for Tom's Obvious, Minimal Language
toml-rs 0.4.4 Active Pythie’s Index: 84A High-Performance TOML Parser for Python written in Rust
pytoml 0.1.21 Maintained Pythie’s Index: 19A parser for TOML-0.4.0
tomli 2.5.0 Active Pythie’s Index: 55A lil' TOML parser
teptris 0.3.33.1 Active Pythie’s Index: 78TOML for Python at libteptris speed (native C extension, no fallback)
Dom's tools for Tom's Obvious, Minimal Language.
Works well withUse together with rtoml: extensions, drivers, servers and companion tools.
fhconfparser Pythie’s Index: 16Provides a config language independent way to read a config file. 318.9K downloads/mo