Skip to main content

A high-performance TOON (Token Oriented Object Notation) parser and serializer for Python, implemented in Rust.

Project description

TOONS - Token Oriented Object Notation Serializer

PyPI version Python Documentation Status CI License

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.

Documentation

📖 Read the full documentation at toons.readthedocs.io.

Quick start pages:

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 json module
  • 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

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

# Install dependencies
pip install -r requirements-dev.txt

# Build extension
maturin develop

# Run tests
pytest

See the Development Guide for more details.

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.

Why isn't TOONS listed among the official TOON community implementations?

Join the conversation on toon-format/toon#275.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toons-0.5.3.tar.gz (60.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

toons-0.5.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (343.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.5.3-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (363.0 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.5.3-cp37-abi3-win_amd64.whl (197.0 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.5.3-cp37-abi3-win32.whl (189.5 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl (550.1 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ x86-64

toons-0.5.3-cp37-abi3-musllinux_1_2_i686.whl (582.3 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl (619.4 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl (511.3 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.5.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (347.0 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

toons-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (373.3 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (454.0 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (344.4 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (335.7 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (366.4 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.5.3-cp37-abi3-macosx_11_0_arm64.whl (303.9 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.5.3-cp37-abi3-macosx_10_12_x86_64.whl (310.0 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

Details for the file toons-0.5.3.tar.gz.

File metadata

  • Download URL: toons-0.5.3.tar.gz
  • Upload date:
  • Size: 60.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.0

File hashes

Hashes for toons-0.5.3.tar.gz
Algorithm Hash digest
SHA256 41d8518ff409b20e4ca63291bfc1e829a83954a792fbae7abd0abb84e5278f74
MD5 611f565d22569c1e8b990e980f1d40c8
BLAKE2b-256 7ea4f5b11bc49c14f9185d0e15208518f751f7c45631e88b9efeef73f459aa24

See more details on using hashes here.

File details

Details for the file toons-0.5.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c811ccfc140551fd2d04b11e408735f3d472d36832fae3b2871932cff5f61308
MD5 d95b00c33cdf3fe2454971cca428b994
BLAKE2b-256 f212b04b80a1790ae59b569cdd6512f4d7ffb92e98254e9f150e6ff40b9854bd

See more details on using hashes here.

File details

Details for the file toons-0.5.3-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for toons-0.5.3-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 f8ce1f88b34373524e64b6216236ffb42f60706ee4e9c6806520a092346ce724
MD5 5f0014d90abfdef16e15ae2e705028a1
BLAKE2b-256 716594849a11c9559eba1a1e75666eecc59037aaeb643bbbd4b8f34fb5c6d5e6

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: toons-0.5.3-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 197.0 kB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.0

File hashes

Hashes for toons-0.5.3-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 fc4f3d61d4af43c4caa7d3f7dc6c95b5bdf5a7c222a16019a361cb2006aa3294
MD5 529c7ea41be89eb85b9564128ab89617
BLAKE2b-256 f30ac693cd3828b02e52e87c4a1bdf883db59b67d74fc391ee353f2d69a93530

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-win32.whl.

File metadata

  • Download URL: toons-0.5.3-cp37-abi3-win32.whl
  • Upload date:
  • Size: 189.5 kB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.0

File hashes

Hashes for toons-0.5.3-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 40f28285453d5a99a26f12bea00aaff7393bae1c6da2ff4d8d5799295947077b
MD5 5aa68843e890bc2b15bb468dc6ece3e3
BLAKE2b-256 288d946c6d0099d8aff642df5a9f7b0f3ec0e841615f15cde6a1c60cdf009774

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1d496e2ce40b3814f8cd5e8a189ea6ac6bd1a6d9a93ecba4c4ba413b9ce90cf4
MD5 40fd2712a5fa04f33f1c59a9cc2cf66d
BLAKE2b-256 2e73e79d95b8306e9293e0bc5e16cee8e57a69e6205a214c84aad989b497376b

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e94603fde044201bc00880e56627cdbfd3ec5cd697fed075d8fcd5d6cd821ee4
MD5 70da8d7cf218f54f76bcadae576026dd
BLAKE2b-256 1805d216117b9fbbd1b5fdb497457eb6f9312fe0afb6adfc3f319afb389f915c

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 d93746c7f7904bc08e2223385bd42cd59adf6c483b3c3a1e44c29b81cd418b58
MD5 d03832686e5058be3330390132092299
BLAKE2b-256 0e4de95a965a2952f6146008563e5d12546214ac9c1ade3f7243cba3a8d9ba6b

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f30ad7d3acd1d676b0c307bca1fa7153f8529947c0c58bf292c8454a445558f6
MD5 2a4b86501461a33dc56fc235a03e2675
BLAKE2b-256 30595ea8663c000ee5dd5839d8c3698dbd45ef629419e01b9d5aefd6d22e0376

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca76918e10136a59cda767cc159baa2fa38b5c2958b493c0b4c52a26aaa50912
MD5 835226791368ed30588509f3c6012735
BLAKE2b-256 9624485da063400264347036b1cb09a7ece3cb408e212575aa16db465a4491ba

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 de9ea8638b7af4d718b94e876d6241b01810341369fe66eec5f9a0833115c8b1
MD5 2bf468c10a9ed9a4c6e7a215f12f44c9
BLAKE2b-256 9d16c8f3fa519c7f4e63ff88701e635cedb8df6953e3e7fb39164d03d3f3b342

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 ef433f625fbdd1d7996cc2a59cd50685bbdc6ba49078c2e5e20a2f4a456db713
MD5 951c6a0229e8760a550c959662d87be0
BLAKE2b-256 0b7d7a912c77531b32a5ebee2fb8b4a5fb26ec4f5575ba76de7fbae7f7b10221

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 4c1486fa4f6acaa07eea07773899a28a2711dd8ae7f1ce91d593ec4b5b1c8f6e
MD5 4855fc3349c9303f26a97751ba4d5771
BLAKE2b-256 92137421d18c4ff7819f372daffd4dc26e91d1173538d63c24c63e522bb4eee4

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 48b40e40ff7ff417e0e1b1f8c8b5e9315caccbb5a89d686341bf23b4252e20a9
MD5 e44557cf999575b8335c1486425b0a21
BLAKE2b-256 9b2b078d78c7cb81af677830079657914d4ec69c952687694af015e9833cfee5

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 ab5a7604a4172a009babf19088a0edc7bf4acadf6a8019387ab0fc609916fb5a
MD5 af3d98181973d269b2acf96a6c6aa9ab
BLAKE2b-256 4bb251cd2c3b28e57bd166d1b7977486ff5c1aab237754144df9025c2034d617

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9bbcf657ef90643217d032622fa6c6ca1831e60caee105b005f70f87a9a2f74b
MD5 9b42a84b60bf9900375307321b5d3f36
BLAKE2b-256 43240c5efde0261be4385a2877dc0621a62924c898778ba3498b927ad32143f5

See more details on using hashes here.

File details

Details for the file toons-0.5.3-cp37-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for toons-0.5.3-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9f29248b1bef7c36705cc9c5f257f3d9141453729c6046341b3013a0801dd9c6
MD5 b9ec7910208dbcd7b12649c12fb0852f
BLAKE2b-256 6b3e1569b1dc2bf001c0c282a2295fdb5f2a885ee44369c095a50bb85d150075

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page