Skip to main content

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).

GitHub GitHub stars

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

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


Download files

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

Source Distribution

totoon-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

totoon-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

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

Hashes for totoon-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b44cd9542e60d5fdd1efb81987d40e929f5c747731e2c8f66d0444e83cb3fcae
MD5 99a39d4e0fe844a9fd0fb0fa704144a0
BLAKE2b-256 cbf3a8e6fe4108a6e14f4c0d0c5bb0ec3b9f130898fe9e3e76f43e92113d8f21

See more details on using hashes here.

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

Hashes for totoon-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 08d735416dace8618b9467f77c2e99c31f3f0952c37a2ba1f7b71b79f1ad0048
MD5 1cad8e4d1b3cac486fd02194ee29622f
BLAKE2b-256 54bea54059b0b2451ad662555dcb452ca7674818989fdc5b7c720e412e913830

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