TOON Format Documentation
Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model for LLM prompts.
What is TOON?
TOON provides a lossless serialization of the same objects, arrays, and primitives as JSON, but in a syntax that minimizes tokens and makes structure easy for models to follow.
TOON combines YAML's indentation-based structure for nested objects with a CSV-style tabular layout for uniform arrays. Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input.
Key Features
Typically 30-60% fewer tokens on large uniform arrays vs formatted JSON
Explicit lengths and fields enable validation and improve accuracy
Removes redundant punctuation (braces, brackets, most quotes)
Like YAML, uses whitespace instead of braces for nested objects
Syntax Guide
Basic Array
JSON:
{
"users": [
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
}TOON:
users[2]{id,name}:
1,Alice
2,BobNested Objects
JSON:
{
"user": {
"name": "Alice",
"role": "admin"
}
}TOON:
user: name: Alice role: admin
Mixed Data Types
JSON:
{
"total": 3,
"active": true,
"items": ["a", "b", "c"]
}TOON:
total: 3 active: true items[3]: a,b,c
When to Use TOON
✅ Use TOON When:
- Sending data in LLM prompts (ChatGPT, Claude, GPT-4, etc.)
- Working with uniform arrays of objects (like database results)
- Token costs are a concern
- You need explicit validation (array lengths, field names)
- Improving LLM accuracy on structured data
❌ Avoid TOON When:
- Deeply nested or non-uniform structures (JSON may be more efficient)
- Semi-uniform arrays (~40-60% tabular eligibility)
- Pure tabular data (CSV is smaller for flat tables)
- API responses that will be parsed by code
- Standard web development (REST APIs, configs, etc.)
Performance Comparison
Key result: TOON achieves 73.9% accuracy (vs JSON's 69.7%) while using 39.6% fewer tokens.
Frequently Asked Questions
Yes, TOON is 100% lossless. Converting JSON → TOON → JSON will always produce identical results.
All major LLMs can parse TOON (ChatGPT, Claude, GPT-4, Gemini, Grok). TOON is just structured text that LLMs can understand.
Typically 30-60% fewer tokens on uniform arrays. Actual savings depend on your data structure. Use our comparison tool to test your specific data.
Use CSV for pure flat tabular data where every token counts. TOON adds ~5-10% overhead but provides structure that improves LLM reliability.