TOONS - Token Oriented Object Notation Serializer
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.
TOONS is listed among the community implementations of the TOON format.
Why TOON?
TOON uses 30-60% fewer tokens than the equivalent JSON, which matters when data goes into a prompt. This example saves 40%:
JSON (26 tokens):
{"users": [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]}
TOON (16 tokens):
users[2]{name,age}:
Alice,25
Bob,30
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
jsonmodule - 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,NaNare 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.
Install
pip install toons
Usage
import toons
# Parse a TOON string
data = toons.loads("""
name: Alice
age: 30
tags[3]: python,rust,toon
""")
print(data)
# {'name': 'Alice', 'age': 30, 'tags': ['python', 'rust', 'toon']}
# Serialize to TOON
print(toons.dumps({"name": "Bob", "age": 25, "active": True}))
# name: Bob
# age: 25
# active: true
# Convert TOON to JSON
print(toons.to_json("name: Alice\nage: 30", indent=2))
# {
# "name": "Alice",
# "age": 30
# }
Files work the same way as in the json module:
import toons
with open("data.toon", "w") as f:
toons.dump({"message": "Hello, TOON!"}, f)
with open("data.toon", "r") as f:
data = toons.load(f)
Documentation
Full documentation: toons.readthedocs.io
- Quick Start - installation and first steps
- Data Types - how Python values map to TOON
- Complex Examples - delimiters, tabular forms, strict mode
- API Reference - full signatures
Development
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.
Contributing
Contributions are welcome. Please read the Contributing Guide, follow Conventional Commits, and run the tests before opening a pull request.
Changelog
See CHANGELOG.md.
License
Apache License 2.0. See LICENSE.
Release files for toons 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| toons-0.8.0.tar.gz | 185.3 kB | Details |
Built distributions (wheels)
Total release size: 4.9 MB
Release files / toons-0.8.0.tar.gz
| Download URL | toons-0.8.0.tar.gz |
|---|---|
| Size | 185.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
876acd3b6e81e24881f5177414247eae5d1d53ba9a86c705b7e42f61916f7664
|
|
BLAKE2b-256 checksum How to use checksums |
c0e3d1e65602c21c6cbabc98796190c2a6e237ac70b9044b7c1873cd8c7309ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-win_arm64.whl
| Download URL | toons-0.8.0-cp314-cp314t-win_arm64.whl |
|---|---|
| Size | 177.4 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows ARM64 |
|
SHA-256 checksum How to use checksums |
24a8888dd3a8f53a5f33e865e286840ab616d8bb9be769539b8ccbeaf5d8a95a
|
|
BLAKE2b-256 checksum How to use checksums |
e33da892a37d8701a032bfa23d37be8e37a5184b946ac65de59a899c60e20d57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-win_amd64.whl
| Download URL | toons-0.8.0-cp314-cp314t-win_amd64.whl |
|---|---|
| Size | 182.8 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
c9e46b985c78deed40ce6636d83f84069b389c97fbd583f1713eabab0f241382
|
|
BLAKE2b-256 checksum How to use checksums |
8e7be2243524e69e800fa31adb889c30e42d430b0a7f5bc4446923e0a0fc9c28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-musllinux_1_2_x86_64.whl
| Download URL | toons-0.8.0-cp314-cp314t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 482.7 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
e81ca5adadcab9f0d0f78afe68cd59150345e15c797230f8bd703c9a75529ec9
|
|
BLAKE2b-256 checksum How to use checksums |
08fd307a705cbac49a84fe62684204e227170ede49c81655da07f7bb3383856a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-musllinux_1_2_aarch64.whl
| Download URL | toons-0.8.0-cp314-cp314t-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 438.5 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
2e30072d385410ecf018cad154b00f1ff91c6153ff4b853ce5d90f33478ece9f
|
|
BLAKE2b-256 checksum How to use checksums |
0bb896c43142cfb9504defa514b5a00f01d387168644104cacd4fa11fdabc893
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | toons-0.8.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 270.1 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
34405329dd3f6508e6134cbd5686b71a83d3c7c6c4bbd5f12954687a73a3e108
|
|
BLAKE2b-256 checksum How to use checksums |
bba9a1ab4911540aabef16397e198a446441457ed984394f44c0361c0a22e2e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | toons-0.8.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 259.6 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
4c499513329f3a74ba815133c20952322110cbb764ea1ef593233713ed6b0b9d
|
|
BLAKE2b-256 checksum How to use checksums |
c5e9b3cff5cf2b578ca857a8dc3f72dbf21ec706097dc678081a398e6d8494bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-macosx_11_0_arm64.whl
| Download URL | toons-0.8.0-cp314-cp314t-macosx_11_0_arm64.whl |
|---|---|
| Size | 250.7 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
acc28b1e18abf9cf39815725c6c6f5d10696e85630ac464b825ab68e89951453
|
|
BLAKE2b-256 checksum How to use checksums |
291822edbdc4b2f202c4b504378c4f008445f273c9bda0cb189dc9859b3ab5ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp314-cp314t-macosx_10_12_x86_64.whl
| Download URL | toons-0.8.0-cp314-cp314t-macosx_10_12_x86_64.whl |
|---|---|
| Size | 263.3 kB |
| Tags | CPython 3.14 CPython 3.14 free-threading macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
0fbe7715e949be294bc47142734bb6059852d7189c430a490c21b3328503f32b
|
|
BLAKE2b-256 checksum How to use checksums |
1f5dc56586e21a816b7888d46150387f033ab9863a175b5cfde0b642f6b6ace4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-win_arm64.whl
| Download URL | toons-0.8.0-cp38-abi3-win_arm64.whl |
|---|---|
| Size | 186.9 kB |
| Tags | CPython 3.8 Windows ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
f10c7d8c3a1dae710c06f16796504a4c950c923442c2cb89394acd4d9994bbc6
|
|
BLAKE2b-256 checksum How to use checksums |
8220d8ca174ea80465fe5fb92cb4d570b95924d62a58d0f52309f25cef659ed5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-win_amd64.whl
| Download URL | toons-0.8.0-cp38-abi3-win_amd64.whl |
|---|---|
| Size | 192.2 kB |
| Tags | CPython 3.8 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
4e6ff6818037dcd1e2d2d28441b868c4538eb0ae7b4a1335f81160b55d7f89b7
|
|
BLAKE2b-256 checksum How to use checksums |
8d7a0c2791df3e8b49555eed71bb0b21f05973ade6caccc86f350586dcba53a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-musllinux_1_2_x86_64.whl
| Download URL | toons-0.8.0-cp38-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 490.5 kB |
| Tags | CPython 3.8 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
1e8b387d3b5f5884b44b98cd44d45e925f7075a5c7a6ca3166ff0701d27d96bb
|
|
BLAKE2b-256 checksum How to use checksums |
07793ab9c468ba99d9a0360c89d2ec748038bd66ed7710a956b22b5c59de7bc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-musllinux_1_2_aarch64.whl
| Download URL | toons-0.8.0-cp38-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 446.0 kB |
| Tags | CPython 3.8 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
55c723d4a9217fe032e196786382cacccf7c1bbc7c064d73d7cb14cb9cc83b70
|
|
BLAKE2b-256 checksum How to use checksums |
b68861e5b742795e29abc4f71d9d4d40528b539ebda92c2f0fa0e64e295683de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | toons-0.8.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 277.6 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
537c26a14d0c34258a53da1da3910a05e251deb19439844012f7d6f5ea4e320c
|
|
BLAKE2b-256 checksum How to use checksums |
a1b2743e28a088c603e20dddfcfb0dcd49587ebdad929381b765ec90a9f4d958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | toons-0.8.0-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 267.0 kB |
| Tags | CPython 3.8 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
99f3264800083b3aae075bfa515e840e01497f26600ea75fde06ddc39a66694b
|
|
BLAKE2b-256 checksum How to use checksums |
3f2a742496f88b37664ac97b87e763ab6a0aa02ca8f3d7c6de01479364954bd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-macosx_11_0_arm64.whl
| Download URL | toons-0.8.0-cp38-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 259.2 kB |
| Tags | CPython 3.8 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b594866ed73423abbc4ee685ffb36b3b35b8770de5222ccfd0bffa3c167880c7
|
|
BLAKE2b-256 checksum How to use checksums |
7ce1645d9cc16444127f7604553f77d8e25f3c001c27d5225fa42a5e7a01618a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / toons-0.8.0-cp38-abi3-macosx_10_12_x86_64.whl
| Download URL | toons-0.8.0-cp38-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 267.9 kB |
| Tags | CPython 3.8 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
1d8e13dd3e302acac8f5669bd59c55aff6e2216e051a7e2bf4ea0fd3c9cb47b0
|
|
BLAKE2b-256 checksum How to use checksums |
90792ab9300bc45f4779f1d200840414e4975592bf359a0c3c4fdfb9187318b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|