Convert any data format to TOON (Token-Oriented Object Notation)
Project description
totoon
totoon - Convert any data format to TOON (Token-Oriented Object Notation)
TOON is a compact data format that reduces token usage by 30-60% compared to JSON when interfacing with Large Language Models (LLMs).
Features
- 🚀 Convert JSON, YAML, XML, and more to TOON format
- 📦 Multi-language SDK support (starting with Python)
- ⚡ High-performance conversion
- 🔧 Easy to integrate
- 📚 Comprehensive documentation
Installation
Python
pip install totoon
Quick Start
Python
from totoon import to_toon
# Convert Python dict to TOON
data = {
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
toon_output = to_toon(data)
print(toon_output)
Output:
users:
name | age
--- | ---
Alice | 30
Bob | 25
Convert from JSON
from totoon import json_to_toon
json_str = '{"name": "Alice", "age": 30}'
toon_output = json_to_toon(json_str)
print(toon_output)
Convert from YAML
from totoon import yaml_to_toon
yaml_str = """
users:
- name: Alice
age: 30
- name: Bob
age: 25
"""
toon_output = yaml_to_toon(yaml_str)
print(toon_output)
Why TOON?
TOON (Token-Oriented Object Notation) is designed specifically for LLM interactions:
- 30-60% token reduction compared to JSON
- Tabular format for arrays of objects (common in LLM data)
- Human-readable while being compact
- Efficient for API calls to LLMs
Example Comparison
JSON:
{
"users": [
{"name": "Alice", "age": 30},
{"name": "Bob", "age": 25}
]
}
~80 tokens
TOON:
users:
name | age
--- | ---
Alice | 30
Bob | 25
~35 tokens (56% reduction!)
Supported Formats
- ✅ JSON
- ✅ YAML
- ✅ XML
- 🔄 CSV (coming soon)
- 🔄 TOML (coming soon)
Language Support
- ✅ Python
- ✅ JavaScript/TypeScript
- ✅ Go
- ✅ Rust
Repository
- GitHub: https://github.com/bug4fix/totoon
- Issues: https://github.com/bug4fix/totoon/issues
- Discussions: https://github.com/bug4fix/totoon/discussions
License
MIT License - See LICENSE file for details
Contributing
Contributions are welcome! Please read our Contributing Guidelines.
Business Model
This project follows an Open Source + Enterprise SaaS model:
- Open Source: Core SDKs are free and open source
- Enterprise: Cloud API, advanced features, and support available for enterprise customers (coming soon)
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 Distribution
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 totoon-0.1.0.tar.gz.
File metadata
- Download URL: totoon-0.1.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b44cd9542e60d5fdd1efb81987d40e929f5c747731e2c8f66d0444e83cb3fcae
|
|
| MD5 |
99a39d4e0fe844a9fd0fb0fa704144a0
|
|
| BLAKE2b-256 |
cbf3a8e6fe4108a6e14f4c0d0c5bb0ec3b9f130898fe9e3e76f43e92113d8f21
|
File details
Details for the file totoon-0.1.0-py3-none-any.whl.
File metadata
- Download URL: totoon-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08d735416dace8618b9467f77c2e99c31f3f0952c37a2ba1f7b71b79f1ad0048
|
|
| MD5 |
1cad8e4d1b3cac486fd02194ee29622f
|
|
| BLAKE2b-256 |
54bea54059b0b2451ad662555dcb452ca7674818989fdc5b7c720e412e913830
|