Registry / serialization / toml-rs

toml-rs

JSON →
library0.3.13pypypi✓ verified 87d ago

A high-performance TOML parser for Python written in Rust, supporting TOML 1.0 and 1.1. Current version is 0.3.12, released regularly with wheel builds for many platforms including wasm. Requires Python >=3.10.

pip install toml-rs
INSTALL
IMPORT
SIG · TOML-RS
T
toml-rs
serializationpythonv0.3.13
Install
2.1s avg
Import
25ms
Disk
17MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.3.13 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✓ —
✓ 2.1s
py 3.11
✓ —
✓ 2.6s
py 3.12
✓ —
✓ 1.9s
py 3.13
✓ —
✓ 1.8s
py 3.9
✕ build_error
✕ build_error
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

loads
✓ from toml_rs import loads
✗ import toml; toml.loads(...)
toml-rs is not the standard library toml; it's a separate package with module name toml_rs.
dumps
✓ from toml_rs import dumps
No common wrong import known.
load
✓ from toml_rs import load
Load from file.
load_with_metadata
✓ from toml_rs import load_with_metadata
Returns parsed TOML with metadata.

Basic parsing with loads() and load_with_metadata().

import toml_rs toml_string = """ title = "Example" [owner] name = "Alice" """ parsed = toml_rs.loads(toml_string) print(parsed["title"]) # Example print(parsed["owner"]["name"]) # Alice # With metadata toml_string = "x = 1" result = toml_rs.load_with_metadata(toml_string, toml_version="1.0.0") print(result.data) # {'x': 1} print(result.meta) # metadata object
Debug
Known issues
gotchaThe module name is 'toml_rs' (underscore), not 'toml'. Do not import toml (standard library) or toml-rs (hyphen).
fix
Use 'import toml_rs'.
affects: >=0.0.0
deprecatedThe toml_version parameter in loads() and load() defaults to '1.0.0' but may be removed in future; specify explicitly if you rely on 1.0 behavior.
fix
Pass toml_version='1.0.0' or '1.1.0' explicitly.
affects: 0.3.x
gotchaTOML strings with carriage return ('\r') not followed by newline ('\n') raise TOMLDecodeError. This is stricter than some parsers.
fix
Normalize input to use '\n' line endings.
affects: >=0.3.3
gotchaload_with_metadata() returns an object with .data and .meta attributes; it does not return a tuple.
fix
Access via result.data and result.meta.
affects: >=0.3.4
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'toml'
Trying to import 'toml' instead of 'toml_rs'.
fix
Use 'import toml_rs' (the module name is toml_rs, not toml).
toml_rs._lib.TOMLDecodeError: TOML parse error at line 1, column 9 ... carriage return must be followed by newline, expected newline
Input contains a bare carriage return character (\r) not followed by newline (\n).
fix
Replace '\r' with '\r\n' or '\n' before parsing.
TypeError: loads() got an unexpected keyword argument 'toml_version'
Using an older version (<0.2.0?) that doesn't support toml_version.
fix
Upgrade to latest: pip install --upgrade toml-rs
Upgrade
Version history
0.3.13latest on PyPI · released May 13, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
22 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources