A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python.
TOONS is a Rust implementation with a Python interface that mirrors the json
module, for the TOON format: a token-efficient serialization format designed
for Large Language Model contexts.
Token counts measured with the Anthropic Claude tokenizer. Try other
tokenizers in the tokenizer playground.
Features
Fast: Rust implementation with PyO3 bindings
Token-efficient: 30-60% fewer tokens than JSON
Familiar API: same shape as the module
json
Spec compliant: TOON v4.1, validated against the official fixtures (see TOON version)
Typed: type stubs ship with the wheel
TOON version
TOONS implements TOON specification v4.1.
Every release is validated against the official conformance fixtures from
spec tag v4.1.1,
vendored under tests/integration/fixtures/ and run on every build.
The v4 features are all supported:
# comment lines, stripped before any other rule
nested field groups in tabular headers
(orders[2]{id,customer{name,country},total}:)
keyed tabular form for objects of uniform objects (users[2:]{age,city}:)
key: [] and [] for empty arrays
the normative decoder number grammar (.5, +5, 0x10, NaN are strings)
The implemented specification version is readable at runtime, as spec
Section 13 recommends:
import toons
print(toons.__toon_spec__) # 4.1 specification version
print(toons.__version__) # 0.8.0 library version
Key folding and path expansion were removed from the specification in v4.0,
so the key_folding, flatten_depth, and expand_paths options are gone.
The indent option is now spelled indent_size, matching the spec's
indentSize; indent keeps working as an alias.
git clone https://github.com/alesanfra/toons.git
cd toons
uv venv -p 3.14
uv sync --frozen
uv run maturin develop --uv # build the extension
uv run --no-sync pytest # run the tests
uv run without --no-sync reinstalls the published wheel over the module
you just built. See the Development Guide
and AGENTS.md for details.
Wheels
Since v0.7.0, binary wheels are no longer built for the following targets,
which had close to no downloads between 2026-04-20 and 2026-05-20:
Linux x86, s390x, ppc64le (0 downloads)
Linux armv7l (6 downloads)
Windows x86, 32-bit (0 downloads)
Source distributions remain available, so toons still installs on those
platforms when a Rust compiler is present.