TOON: Token-Oriented Object Notation
What is TOON?
TOON (Token-Oriented Object Notation) is a compact data format designed to minimize token usage when communicating with Large Language Models (LLMs). It reduces API costs by 30-60% compared to JSON while maintaining human readability.
Why TOON Matters
LLMs like GPT, Gemini, and Claude charge per token. TOON optimizes data transfer by:
Core Syntax
Objects
user:
name: John Doe
age: 30
email: john.doe@example.com
Arrays
users[2]{id,name,email}:
1,Alice,alice@example.com
2,Bob,bob@example.com
Nested Data
company:
name: TechCorp
departments[2]{name,budget}:
Engineering,500000
Marketing,200000
JSON vs TOON Comparison
JSON (85 tokens):
{
"company": {
"name": "TechCorp",
"departments": [
{"name": "Engineering", "budget": 500000},
{"name": "Marketing", "budget": 200000}
]
}
}
TOON (40 tokens - 53% savings):
company:
name: TechCorp
departments[2]{name,budget}:
Engineering,500000
Marketing,200000
Key Benefits
Implementation
TOON works as a translation layer:
Libraries:
Basic Usage:
const toonData = jsonToToon(jsonInput);
const llmResponse = await callLLM(toonData);
const result = toonToJson(llmResponse);
Use Cases
Best Practices
Limitations
Getting Started
TOON represents the future of AI-optimized data communication, making LLM applications more efficient and cost-effective.