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.1.tar.gz (101.7 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.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (338.3 kB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

toons-0.5.1-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl (357.8 kB view details)

Uploaded PyPymanylinux: glibc 2.5+ i686

toons-0.5.1-cp37-abi3-win_amd64.whl (191.5 kB view details)

Uploaded CPython 3.7+Windows x86-64

toons-0.5.1-cp37-abi3-win32.whl (184.8 kB view details)

Uploaded CPython 3.7+Windows x86

toons-0.5.1-cp37-abi3-musllinux_1_2_x86_64.whl (544.5 kB view details)

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

toons-0.5.1-cp37-abi3-musllinux_1_2_i686.whl (577.2 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ i686

toons-0.5.1-cp37-abi3-musllinux_1_2_armv7l.whl (608.9 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARMv7l

toons-0.5.1-cp37-abi3-musllinux_1_2_aarch64.whl (506.0 kB view details)

Uploaded CPython 3.7+musllinux: musl 1.2+ ARM64

toons-0.5.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (341.5 kB view details)

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

toons-0.5.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (367.8 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

toons-0.5.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (449.1 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

toons-0.5.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (338.6 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

toons-0.5.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (329.9 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARM64

toons-0.5.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl (360.8 kB view details)

Uploaded CPython 3.7+manylinux: glibc 2.5+ i686

toons-0.5.1-cp37-abi3-macosx_11_0_arm64.whl (297.6 kB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

toons-0.5.1-cp37-abi3-macosx_10_12_x86_64.whl (303.6 kB view details)

Uploaded CPython 3.7+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for toons-0.5.1.tar.gz
Algorithm Hash digest
SHA256 61d7b383d314981ac0b5d5b7d811860a8c8b23c70f5809164cbe06468297d1d4
MD5 ae09819aea82a2c34f3f82d02a817ac9
BLAKE2b-256 64917ed279a6ca4d1c60797f4706b64791bb96b41e99441c2564ce8beef6a691

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7d79eb894432ca7440f8637cb9e5b1aab3e641259799fac40094c51eb31e7a9d
MD5 0d216b98252ca0cf83b3f725bbe3b40b
BLAKE2b-256 3b91081c91a850f385d1db1c218e435ab3065a7c64365d600f9cade8fd8e661a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-pp311-pypy311_pp73-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 1cb038f51bd4a2f869b7a1de6fc4bcaf7b343c4c8af2b0b1ed134823d18bd4bc
MD5 f628bd107d60aeacfbfa8f6ed3c25e87
BLAKE2b-256 e296e70d16d588d2f4e41e6f63ed1a267dc1bbeaf43582c342b52de3609ca20d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toons-0.5.1-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 191.5 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.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 11922e72457fc5f70ea0d46fba27b3f2f71e383f6e3e778cd298d31a75835fb5
MD5 01d5fec7ae490a59191c9a153776f227
BLAKE2b-256 832872151811ca619243cdd1eb6b481bccab5443a5bfab95a7fd71babb628b4b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toons-0.5.1-cp37-abi3-win32.whl
  • Upload date:
  • Size: 184.8 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.1-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 757465a04201a4b536b6be4386866831c606119f498101bed71c4a7ecba9adcb
MD5 b9c4ec2fb712727f2b766f9796b35e1c
BLAKE2b-256 318824ffc1257aaea9dd7f6e8fd0f72f42105d844fc6a086946accfdd1de5840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0198287f2e91bb48373637d7485e1b0fad7b8dc5b69ca7277970bed6bbdf84c2
MD5 2aad14b1db3a95adc47b5b6b1f9cd48e
BLAKE2b-256 b280f075eefe97e10e17a04cabf7e8870b610f7189935380990231cf9c9580d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 a739ff4ab9504065c3e4f3fc0f3a57b309b2e926b4267275f433c959771b8572
MD5 8c9f59d5ff5225b06801e90951b2a075
BLAKE2b-256 07de7d9b9aab896fab488ae4af3b7482bc8a56fa7c2bd4ba4e7fea3dd7c7ee58

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 09e36f0ef996effe7e320c6ec2bd81062341774e40507b2feaf9a22fa4754c86
MD5 b48f9d74c41aa480b6d6af1fc50eef8c
BLAKE2b-256 e64f066ca28a03d03a457fe2c831a240e4ecb90ecbfdef8286e9d82d1bbf808d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 74f9a468676ba2827d0129b4c83471859c4a9de19862e80d29cb1d0694c75718
MD5 735b8cf0bd16fd9289b0bc74f00fd923
BLAKE2b-256 709d260de4f5c012fd9146014d210c12f758e8959c34fde799ea7f1ccad0521f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2250087e87d13e1435f6a03d0ce4659f0baa058fe44fb84964de0af78cd8c5c5
MD5 f532592a85ffb9f5471925f6236d1c28
BLAKE2b-256 f5c81193d5667e82deb01ac52d33c0d1ef6803921c26b6ce49bfd714bd5c2dde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 01fe15586f9a8bd5a8c13edfe09fd3379c2659dacaba48da8aa30825b4301f03
MD5 e8d78f13b2bbe1864d93265b2f66b177
BLAKE2b-256 90be1ba007b3c08b2d767f962ca3a7fc4728cbb53ccdb40513f3983ffde03fc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 5eda4fd413ddc565279221c2cd668e9701505f7678203261ccc8bbdd0551859e
MD5 61a53061f8a7da24eb48622203fd01e3
BLAKE2b-256 543909a25c7c6b3b7a708a265b9af5600e546be67ddd325bb63c8459f373ed6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 a5e9ac9e4d86e9ff85fa9314ac118828a3b79f05d403ded8061b7d8abfc34327
MD5 a8a3e202982475545b5b77cdee385a4a
BLAKE2b-256 2445e154a18686a4a9ed8ccf538b42da371563491795d1e6d5ed365c1ae7c378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 df6bbe49e884355591e749129728632b4c180b93d78f1c443689f4df6ade9639
MD5 d9900f2158ea58b34fb86711bc556dd4
BLAKE2b-256 f45346d678081252666543c59c8ef87544e8ca32501278938142cdbe9daa16a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 678db466b6eef00a746b1bd554060ae026d032517cc65e8e61bf1ad490555aaf
MD5 992990c8b2876cd3d2ef7c5f38a088fc
BLAKE2b-256 2dddc1e2e63b2b227396785af4152cb7225e3921e5207507385904b9c1e8898b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 da07718d57db8340e744870e8594a535436d902d968670c37af914eaf19bb9c6
MD5 76b8710a177e7c7da8aa2a21fc0ec9bc
BLAKE2b-256 7328cc86374babcdc622cff84ca814afe8e4a6bd829204c0ee92e493f97cd2f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for toons-0.5.1-cp37-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 b62d291f19d9c6d53810314aa7452f646419375644c92059a4eac8d0ad30b256
MD5 b26c5fde83cedca5ca670ade4b56b25c
BLAKE2b-256 05f2659dd06c51465b7eca1035e21db51bbedbac00566c234f4ce6d824dfd74c

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