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.

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.2.tar.gz (90.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.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (340.7 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.5.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (360.5 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.5.2-cp37-abi3-win_amd64.whl (194.0 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.5.2-cp37-abi3-win32.whl (186.9 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.5.2-cp37-abi3-musllinux_1_2_x86_64.whl (547.5 kB view details)

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

toons-0.5.2-cp37-abi3-musllinux_1_2_i686.whl (579.5 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.5.2-cp37-abi3-musllinux_1_2_armv7l.whl (611.8 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.5.2-cp37-abi3-musllinux_1_2_aarch64.whl (508.2 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.5.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (344.1 kB view details)

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

toons-0.5.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (370.2 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.5.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (451.3 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.5.2-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (341.6 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.5.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (332.8 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.5.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (364.1 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.5.2-cp37-abi3-macosx_11_0_arm64.whl (300.8 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.5.2-cp37-abi3-macosx_10_12_x86_64.whl (306.8 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.2.tar.gz
Algorithm Hash digest
SHA256 f2db1f75d95e7b118399a19d0dbcc2fd128b7ea0f8047c01cddb1f85e03d976f
MD5 a22034c0396ca42eef9f7477e70ad0bc
BLAKE2b-256 3ff2d54096386b7788e03faf002a2f65a3b18865a03bee1494d61b68daa40c6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 39d8bc286843e95d9b054b4cfa80097a0300673ce5e85c40572a3df8edb30f0d
MD5 a749352d2554c7a3dadd2d3c3c00318e
BLAKE2b-256 44ca9ac107887b21543c56acf26a9af4106e9ebe580d5994d3be47eca60d6ea3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 08091dda1fd73efe5e6d912f414dafaef337341456fa4f293489f03ceae86224
MD5 3f02309e49f037d0dbd16a449461ed96
BLAKE2b-256 53ab311d50a4b63e9df6e7c800f36c60950589ff49367915f647756dffdba3d9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 b99219a9dee7de101cb2c41a322c8badf20bf2787b229b62be7830196a91646d
MD5 f1229ed3cd536bdc9cd2ea0275dd7958
BLAKE2b-256 75a83eeb6910ae690763ca110bee2e12b2a536dad2c276bfc2a4cb38d2f6c7a0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.2-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 6b6637f2605d42f73c2b108ea657db6f4612d133faa6b0fc61ebec780ac38c43
MD5 300fc8ae57cea4692cd1d913b32694c9
BLAKE2b-256 9d9d982a90f90b4adf0ac3d435a50157f79332788f7d49c83e5397fe4ed8fbcc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d291ca910520166ce94ea1ed02e41b6aa37a7e7201f3cd82da6ee6d255dae212
MD5 b1fcf7c6b07e6458b79a7b7e28b318f6
BLAKE2b-256 5b36a0fc8a06d14891511bb489912eecd0ebb35043b64407c9769ca67682739e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 f0c69b7b8e4ad50bea96fc9391058983caaf948c7a9c59e2315e2a6711cbc4fe
MD5 f3dcc25c7f74112b0f1236a58c36d978
BLAKE2b-256 40c79a3b547980978d85f60caf20d16ff0ae15c435bb32c81473b9b63298693b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 5316ef0ff48faac69425e21913efb9a54b65b3219f736b9c33013de0399c4110
MD5 2485e9a02d128760f92f1311d5b002c6
BLAKE2b-256 cc3224c42ff5c4e64bd6f65e46245045ff89229c948fb49858a95e49f02429b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 1feb07b10b1cddf0642b0b674ea2f219fb3c498c68be383abde16f001ec21a02
MD5 ad419db68502ba714efaa09384f5677c
BLAKE2b-256 7e87b813647a6e175b2b5f130619cff3ca0c155087c9c923397f713252fd81be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c831c966c7d20aa82c3902949bea8de7489e9b8c5c246b7e27953b2290634864
MD5 ace7596da26d25965e4f404027e6d31e
BLAKE2b-256 8566a6142f1321ca5c36e5b9f8df57acd01a3b0d0843910cacb174051a58692b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 a8d73c0b74806284e395a05f5545def63d0a514763eea35cdfce3dd947273484
MD5 1d6af3a8a3ba06e0237cf2233b179ba7
BLAKE2b-256 eeed4dc5539c19bb641638db75d8cb957d6a02718344bcb9b4c02d1483bba20f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 64365663c8ee406809fb21839c3d05f1f6a1625f5db66881768a72519674c093
MD5 d8651fb21d5d3f428d5c07bb7114ce01
BLAKE2b-256 653370ebdabe8e530018d6beeb29a2e4e847bb782669e16f0cddad8c9eb18f32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 eac2846301cf89a0f7e0dead1605e5385aa5f0abdf14be52454a9ecb11032193
MD5 e89ee8875400329c0e07dbba69ef3016
BLAKE2b-256 57bcd5c1b05ea73413b57fefe805a53541ca8560e30f77a9b2fe4d768ef3ab44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1981469c1c9196a525f84e683d39d588050e94868cf30416bd90040c0c07b190
MD5 cef8a83f0816e066c6afdee381d0b82e
BLAKE2b-256 431448973b124a11dcf72f2e1382453c0eda0c9f69e8c8114b20ff176567f5d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 380059a8746c11ee5032672c78e730cf6598dcd65a442614edafd2ccc762f1e8
MD5 e40c91f99d3c0b5f3e04dac6cfb72dcc
BLAKE2b-256 a9296fc8c8c7fe7704506b21f5932e1558e1752da107b1a24cd4c8673a889a6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8abfb1bb166eb09525985007befc0ca160b329b22e39efc4492ed3ae318e9415
MD5 1015ec4ce1582d0326e31cdb46999d1a
BLAKE2b-256 42ff5e227d03ebe7d01363b4ffe133d417ce1aa5dca3d7b607638edf9cd0d395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.2-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1e9aedad5813471f73411728f45c9906d1c98264980ca4f4a0369f745634eb8f
MD5 74e8a3d6cf8019b351e30025543cd59d
BLAKE2b-256 7ef4e08cf0eef8cde5b7ce40538a1c2ffe33504d9a19187343619daa40eec455

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