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

Go

In your Go project (must be in a directory with go.mod):

go get github.com/bug4fix/totoon/go@v0.1.0

If you don't have a Go module yet, initialize one first:

go mod init your-project-name
go get github.com/bug4fix/totoon/go@v0.1.0

JavaScript/TypeScript

npm install totoon

Rust

Add to your Cargo.toml:

[dependencies]
totoon = "0.1.0"

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[2]{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[2]{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.1.tar.gz (10.9 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.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file totoon-0.1.1.tar.gz.

File metadata

  • Download URL: totoon-0.1.1.tar.gz
  • Upload date:
  • Size: 10.9 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.1.tar.gz
Algorithm Hash digest
SHA256 a373c2c36ddc489af7c56bed090ee5edde2b71d634d5025d0be5e30130053d9b
MD5 f3b02ecda1ee65aac9627e0eefc9995c
BLAKE2b-256 6a53711daa0eda78398911f52c3363b654be3808b965289e12fe113bcd5b0b82

See more details on using hashes here.

File details

Details for the file totoon-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: totoon-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e1365df2af9006b733ec219a9304ca31ab35a9a9cf0bfac9bf33ae053b3841f0
MD5 0adddb48ad3ac27cf7bfe0daa3ee53b4
BLAKE2b-256 24b7f1102b022386e649ba15e4c238f3378c6e5f8645464da7b82ccbb9fb003d

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