A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python, implemented in Rust.
Project description
TOONS - Token Oriented Object Notation Serializer
A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python.
TOONS - Token Oriented Object Notation Serializer - is a fast Rust-based library that provides a Python interface mirroring the json module API, making it easy to work with the TOON format—a token-efficient data serialization format designed specifically for Large Language Models.
TOONS is officially listed among the community implementations of the TOON format.
Documentation
📖 Read the full documentation at toons.readthedocs.io.
Quick start pages:
- 🚀 Getting Started - Installation and first steps
- 💡 Examples - Practical usage examples
- 📚 API Reference - Complete API documentation
Why TOON?
The TOON format achieves 30-60% fewer tokens than equivalent JSON, making it ideal for LLM contexts where token count impacts costs and context capacity.
In this simple example we can achive -40% with respect to JSON:
JSON (26 tokens):
{"users": [{"name": "Alice", "age": 25}, {"name": "Bob", "age": 30}]}
TOON (16 tokens):
users[2]{name,age}:
Alice,25
Bob,30
Note: Calculations were done using Anthropic Claude tokenizer, you can experiment with different tokenizer here
Features
- 🚀 Fast: Rust implementation with PyO3 bindings
- 📊 Token-Efficient: 30-60% fewer tokens than JSON
- 🔄 Familiar API: Drop-in replacement for
jsonmodule - ✅ Spec Compliant: Full TOON Specification v3.0 support
- 🐍 Python Native: Works with standard Python types
Quick Start
Installation
pip install toons
Basic Usage
import toons
# Parse 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
user = {"name": "Bob", "age": 25, "active": True}
print(toons.dumps(user))
# name: Bob
# age: 25
# active: true
# Convert TOON to JSON
print(toons.to_json("name: Alice\nage: 30", indent=2))
# {
# "name": "Alice",
# "age": 30
# }
File Operations
import toons
# Write to file
with open("data.toon", "w") as f:
toons.dump({"message": "Hello, TOON!"}, f)
# Read from file
with open("data.toon", "r") as f:
data = toons.load(f)
Development
# Clone repository
git clone https://github.com/alesanfra/toons.git
cd toons
# Create venv and install dependencies
uv venv -p 3.14
uv sync --frozen
# Build module
uv run maturin develop --uv
# Run tests
uv run pytest
See the Development Guide for more details.
Targets
Starting with v0.7.0, to optimize GitHub Actions free-tier credits, we no longer build binary wheels for these targets:
- Linux x86, s390x, and ppc64le, since we had 0 downloads during the period from 2026-04-20 to 2026-05-20
- Linux armv7l, since we had only 6 downloads during the period from 2026-04-20 to 2026-05-20
- Windows x86 (32-bit), since we had 0 downloads during the period from 2026-04-20 to 2026-05-20
Source distributions will remain available, so you will still be able to install toons if you also have the Rust compiler installed.
Contributing
Contributions are welcome! Please follow Conventional Commits and run tests before submitting.
See Contributing Guide for details.
License
This project is licensed under the Apache License 2.0. See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file toons-0.7.0.tar.gz.
File metadata
- Download URL: toons-0.7.0.tar.gz
- Upload date:
- Size: 234.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d196a29319bf4ec1481d1f06a05017b859652d112a52eb7071d33c6da28b8193
|
|
| MD5 |
ddf25f8c51a53817ff05c0e50bc58d78
|
|
| BLAKE2b-256 |
ed231d9a6fdc56dccf9c7d22377618adff8d25a12a9214a8fab5c8286e50c527
|
File details
Details for the file toons-0.7.0-cp314-cp314t-win_arm64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-win_arm64.whl
- Upload date:
- Size: 190.3 kB
- Tags: CPython 3.14t, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cac4faa2f3f8da96bc13ccad8cf554f82810f681b02ea27d0a4f79bed3e7ac83
|
|
| MD5 |
46dbab90d569faa465891f5b8692bc9e
|
|
| BLAKE2b-256 |
4c4f4b627ec63f45cafd071b449678567ca57342715dff797159dc34b6e91fa4
|
File details
Details for the file toons-0.7.0-cp314-cp314t-win_amd64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-win_amd64.whl
- Upload date:
- Size: 196.4 kB
- Tags: CPython 3.14t, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b987602c142b945745b2379b8079171fd6d928b4edd6e2162a3f735db6ca73d7
|
|
| MD5 |
f68d71cc7ce52270198adcc1ee6a8162
|
|
| BLAKE2b-256 |
27a6948b6b2639849d488a6f4310c8f9abb3486250d130e467e758f9ce79b0b2
|
File details
Details for the file toons-0.7.0-cp314-cp314t-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 543.3 kB
- Tags: CPython 3.14t, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
637994ae2e58782a35d0c5ab0b16c802624c3e6850da41250ba3c953118bce49
|
|
| MD5 |
bee05af44babaffa71d31ded1138e867
|
|
| BLAKE2b-256 |
7b7becefbc3fd2d89a8240c347bcc81bd19fb821c9b141c3ec3479ce0c9e5af4
|
File details
Details for the file toons-0.7.0-cp314-cp314t-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 508.4 kB
- Tags: CPython 3.14t, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1bb17238ac0853b92f01452c1cf438157b0b4d602ec2e2c9f425ee57cd81a41b
|
|
| MD5 |
a255f60cc372f270061bfe634c126308
|
|
| BLAKE2b-256 |
eeffde05d3bbe0c8b860c71d4d025b6306ee66a988efc1bcd3fe43a419cb717a
|
File details
Details for the file toons-0.7.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 341.0 kB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5468da364bbb3eadd860495148b035f74f9e51b3c83ed8ea9f761938b2a602d1
|
|
| MD5 |
6d7c9f505d3ef616d021f69cbcf4ec87
|
|
| BLAKE2b-256 |
fe24806d3b3c9d86ca202a858d5dcaa862616cd3ee5e52cf9507b2fe6e3acb4f
|
File details
Details for the file toons-0.7.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 332.6 kB
- Tags: CPython 3.14t, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b28eb732f13b1909eb0ac9d32f4e39b6f279081fdaf24f0bce320dbf4cde015f
|
|
| MD5 |
cf6fda635b8e0b08be5aaedefca6a6c1
|
|
| BLAKE2b-256 |
19937d5162a15f46ddc794f16aeb0eb8b12e39d02c6a585b13ff2425b8758970
|
File details
Details for the file toons-0.7.0-cp314-cp314t-macosx_11_0_arm64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-macosx_11_0_arm64.whl
- Upload date:
- Size: 300.8 kB
- Tags: CPython 3.14t, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30bb78650744dfe53a080d683e5b55c3e90fa24d8f1713bb4237d66282e92d9c
|
|
| MD5 |
da44b5c766897c2c9b8429b68a85b1e9
|
|
| BLAKE2b-256 |
4136dff71444f52f82031c8f4a86f2a212d8d7bdb05e00f8559144e6ff3b31b7
|
File details
Details for the file toons-0.7.0-cp314-cp314t-macosx_10_12_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp314-cp314t-macosx_10_12_x86_64.whl
- Upload date:
- Size: 304.4 kB
- Tags: CPython 3.14t, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08f380080e3a54ad53ed6baa1eaa35d4767a7e31436bd05af97b3cc00a6936b5
|
|
| MD5 |
8e0d99dc4bcaf5df518214943cadeb1d
|
|
| BLAKE2b-256 |
7d23b45ad15a8eb21a9109e7fe9bbd04e005b4ea8c35b9dea98023f1a585baeb
|
File details
Details for the file toons-0.7.0-cp37-abi3-win_arm64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-win_arm64.whl
- Upload date:
- Size: 196.2 kB
- Tags: CPython 3.7+, Windows ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1f53e0c9f40439f426050050f34a1e8b495ff4f702bfa460142929ad7e08c8c
|
|
| MD5 |
bcf75b8bc4984a1f38b1f081f8fb5e2e
|
|
| BLAKE2b-256 |
049ebfa4d07d215ea248818b85bc1bec8664eec1728e0704c773a252c4ac7d82
|
File details
Details for the file toons-0.7.0-cp37-abi3-win_amd64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 202.4 kB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56c79eb7e3a9155a564f5ca1fe10f2a93e0e534c82bc9d7c7c047267e472a2f5
|
|
| MD5 |
7d334cbd68b98d77e2009af9382e04b3
|
|
| BLAKE2b-256 |
65fa43f86b3862448159ca6434942822aa31dec02b848967474e94cc1f568154
|
File details
Details for the file toons-0.7.0-cp37-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 551.9 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
611d3db35614ec8f5f7c00accb38787c4db0e34f98bdbc0746e196cab32d45ba
|
|
| MD5 |
fdf9a3400f6929205ca79d493e201a49
|
|
| BLAKE2b-256 |
aec5bb5f09db2100631bef2ab39545611958545f6ef3b7d0f56d85af341fd0f8
|
File details
Details for the file toons-0.7.0-cp37-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 516.0 kB
- Tags: CPython 3.7+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e92ed900fee3a7db0467573bba29c876a1701827836b895d13891a3f5d04567
|
|
| MD5 |
e462eef75c8f60d750ba42f3d74d1b21
|
|
| BLAKE2b-256 |
5dbdd495738cc5e1c201a864a75b0520fdb74fcd2a8c631a61efc993fb8f992f
|
File details
Details for the file toons-0.7.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 348.8 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18fd8f455c2bfa6655c4eaf931dd8e321be0b53a4f2acbc91e77f72843a0f7b9
|
|
| MD5 |
01649f494b67a1d9ecd0681116541a00
|
|
| BLAKE2b-256 |
41396e3c0752b7a1f693fb7082ecc5d3757884537a102d2c846a5a24d7de4b47
|
File details
Details for the file toons-0.7.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 339.6 kB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b45b0a429c22e3b0e7f658d8cbfeb03b1ab4798b2323c7c119fe5029fdaaf1c
|
|
| MD5 |
ee8a95c96a6221e8ea8e2e2761be224a
|
|
| BLAKE2b-256 |
fde5032c014b33cf954ef502326de78466e6ce440f3419b6c9d54721a895936a
|
File details
Details for the file toons-0.7.0-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 308.2 kB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10681fd930ee555df213fe0a19675ddd1095f4291999ab507adb0833fa01e47d
|
|
| MD5 |
f98917cf2d328857b98b8815772e55f5
|
|
| BLAKE2b-256 |
97e6cd600e0461cc9e7b74d8723e010da92efe90136350d9835af1a9f10bfa0e
|
File details
Details for the file toons-0.7.0-cp37-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: toons-0.7.0-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 312.5 kB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.15 {"installer":{"name":"uv","version":"0.11.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}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7933216d41175af1747d4475ae2f947178ac45fd7f8b839a5bcbda57b5c99301
|
|
| MD5 |
e78396f3c02c1af4af2e4b711dd7605b
|
|
| BLAKE2b-256 |
bc432d4d6cd43635130154a57fd45cee8494fd66c4ae73d0d9c17331ebf30637
|