TL;DR: TOON (Token-Oriented Object Notation) is a new data format designed specifically for LLMs that can reduce token usage by up to 60%, slashing API costs and improving AI processing efficiency compared to traditional JSON.
Introduction
If you've worked with Large Language Models (LLMs) like GPT-4, Claude, or Llama, you've likely encountered the challenge of structured data output. For years, JSON has been the de facto standard for getting structured responses from AI models. But there's a new contender in town: TOON (Token-Oriented Object Notation).
This blog explores why TOON might be the future of AI data interchange and when you should consider making the switch.
What is JSON?
JSON (JavaScript Object Notation) is a lightweight, human-readable data format that has dominated data interchange for over two decades. It's:
- Easy to read and write
- Language-independent
- Universally supported
- Self-describing
JSON Example
{
"products": [
{
"id": 101,
"name": "Wireless Mouse",
"price": 29.99,
"inStock": true
},
{
"id": 102,
"name": "Mechanical Keyboard",
"price": 89.99,
"inStock": true
},
{
"id": 103,
"name": "USB-C Hub",
"price": 45.0,
"inStock": false
}
]
}
Token count: ~85 tokens
What is TOON?
TOON (Token-Oriented Object Notation) is a data format specifically designed for AI applications. It was created to address a fundamental problem: LLMs charge by tokens, and JSON is token-expensive.
TOON's core principles:
- Declare once, use many: Field names appear only once
- Compact syntax: Minimal delimiters and whitespace
- AI-optimized: Designed for how LLMs tokenize and process data
TOON Example (Same Data)
products[3]{id,name,price,inStock}:
101,Wireless Mouse,29.99,true
102,Mechanical Keyboard,89.99,true
103,USB-C Hub,45.00,false
Token count: ~35 tokens (59% reduction!)
Side-by-Side Comparisons
Example 1: Nested Structure
JSON:
{
"users": [
{ "id": 1, "name": "Alice", "email": "alice@example.com", "role": "admin" },
{ "id": 2, "name": "Bob", "email": "bob@example.com", "role": "user" },
{
"id": 3,
"name": "Charlie",
"email": "charlie@example.com",
"role": "user"
}
]
}
TOON:
users[3]{id,name,email,role}:
1,Alice,alice@example.com,admin
2,Bob,bob@example.com,user
3,Charlie,charlie@example.com,user
| Metric | JSON | TOON | Savings |
|---|---|---|---|
| Tokens | ~95 | ~40 | 58% |
| Characters | 298 | 142 | 52% |
Example 2: Simple Object Structure
JSON:
{
"settings": {
"theme": "dark",
"language": "en-US",
"notifications": true,
"autoSave": true,
"fontSize": 14
}
}
TOON:
settings{theme,language,notifications,autoSave,fontSize}:
dark,en-US,true,true,14
Benchmark Results
According to real-world benchmarks, here's how JSON and TOON compare:
| Dataset Size | JSON Tokens | TOON Tokens | Reduction |
|---|---|---|---|
| 10 rows | 452 | 189 | 58% |
| 100 rows | 4,523 | 1,892 | 58% |
| 1,000 rows | 45,230 | 18,920 | 58% |
Cost Impact at Scale
Consider an application making 10,000 queries per day, each with 1,000 rows of context data:
| Format | Daily Tokens | Monthly Cost (GPT-4) |
|---|---|---|
| JSON | 452M | ~$108,000 |
| TOON | 189M | ~$27,000 |
| Savings | 263M | ~$81,000/month |
TOON Syntax Deep Dive
Basic Structure
objectName[count]{field1,field2,field3}:
value1,value2,value3
value1,value2,value3
Key Rules
-
Header declaration:
name[count]{fields}:defines the schema - Data rows: Comma-separated values, one entry per line
- No quotes needed: Unless values contain commas
- Nested objects: Use dot notation or nested declarations
Handling Special Cases
Values with commas:
products[2]{name,description,price}:
"Widget, Deluxe",A premium widget,29.99
Basic Widget,Simple and affordable,9.99
Null values:
users[2]{name,nickname,email}:
Alice,,alice@test.com
Bob,Bobby,bob@test.com
When to Use JSON vs TOON
Use JSON When:
- Building traditional APIs or web services
- Interoperability with existing systems is critical
- Human readability is the priority
- Using standard JSON tooling (validators, parsers)
- Data isn't being sent to an LLM
Use TOON When:
- Sending structured data to LLMs as context
- Requesting structured output from AI models
- Processing large datasets with AI
- Token costs are a significant concern
- Building AI-first applications
Potential Drawbacks
While TOON offers significant advantages, consider these limitations:
- Learning curve: Teams need to learn a new format
- Tooling: Less ecosystem support compared to JSON
- Parsing complexity: Custom parsers may be needed
- Edge cases: Complex nested structures can be tricky
- Not human-first: Optimized for machines, not readability
- Model precision: We can reduce the tokens cost, but if that impacts the model accuracy, it could be a real problem.
The Future of AI Data Formats
As AI usage scales and token costs remain a factor, we'll likely see more specialized formats like TOON emerge. The key insight is that formats designed for human developers aren't necessarily optimal for AI systems.
TOON represents a fundamental shift in thinking: design for the consumer, not just the producer. When the consumer is an LLM, token efficiency matters.
Conclusion
JSON isn't going anywhere—it remains the backbone of web APIs and data interchange. But for AI-specific use cases, TOON offers compelling advantages:
- 58%+ token reduction
- Significant cost savings at scale
- Faster processing times
- Cleaner context windows
If you're building AI applications where structured data is a core component, TOON deserves serious consideration.
Top comments (0)