The data serialization format designed specifically for Large Language Models. Reduce token costs, improve comprehension, and maintain human readability.
JSON was created in the early 2000s as a data interchange format for web applications. It's human-readable, universal, and has served us well for over two decades. But in the age of AI and Large Language Models, JSON has a critical flaw: it's incredibly verbose.
Every key and string value is wrapped in quotes, consuming unnecessary tokens
In arrays of objects, the same keys are repeated for every single record
Braces, brackets, colons, and commas everywhere – all counting as tokens
In LLM interactions, tokens are currency. Every character you send costs money. When you're working with large datasets or making thousands of API calls, JSON's verbosity directly impacts your budget:
{
"users": [
{
"id": 1,
"name": "Alice",
"role": "admin",
"active": true
},
{
"id": 2,
"name": "Bob",
"role": "user",
"active": false
},
{
"id": 3,
"name": "Charlie",
"role": "editor",
"active": true
}
]
}
users[3]{id,name,role,active}:
1,Alice,admin,true
2,Bob,user,false
3,Charlie,editor,true
That's 249 tokens saved on just 3 records!
TOON (Token-Oriented Object Notation) was designed from the ground up with LLMs in mind. It's a lossless serialization format that maintains all the structure and data of JSON, but optimizes for token efficiency and LLM comprehension.
For uniform arrays of objects (the most common case in structured data), TOON uses a CSV-style tabular format. Declare the schema once, then list values as rows.
For nested objects, TOON uses indentation instead of braces. This is familiar to developers and natural for LLMs to parse.
TOON only quotes strings when absolutely necessary. Simple values, numbers, and even strings with spaces don't need quotes.
Explicit array lengths and field declarations help LLMs track structure, reducing errors when generating or validating data.
Independent benchmarks show TOON's advantages in both token efficiency and LLM comprehension:
TOON adds only 6% overhead vs CSV while providing full JSON structure and validation
TOON achieves higher accuracy while using 39.6% fewer tokens than JSON
This metric balances both accuracy and token cost, showing TOON's overall superiority for LLM interactions.
Multiple records with the same fields - TOON's sweet spot
Reduce token costs for data-heavy prompts
API responses, database exports, analytics data
Retrieval-augmented generation with structured context
Training data with reduced token overhead
Compact data exchange in multi-agent systems
Complex trees with 0% tabular eligibility
Arrays where objects have different field sets
Use CSV instead - it's more efficient
No need to convert if you're not using LLMs
JSON is native to JavaScript environments
JSON Schema has mature tooling
You don't have to choose one format forever. Many teams use JSON for internal APIs and storage, then convert to TOON only when sending data to LLMs. This gives you the best of both worlds: mature JSON tooling for your application layer, and token-efficient TOON for AI interactions.
Estimated monthly savings for a service processing 1M records/day at GPT-4 pricing
Fit 2.5x more records in the same context window compared to formatted JSON
Average reduction in generation time due to fewer tokens to process
Ready to start saving tokens? TOON is easy to integrate into your existing workflow.
Use our online converter to see how TOON handles your data. Get instant token count comparisons.
Open ConverterAdd TOON to your project with npm, Python pip, or any of our 15+ language implementations.
Convert your data to TOON before sending to LLMs. Start saving tokens immediately.
See Featuresimport { encode } from '@toon-format/toon';
const data = {
orders: [
{ id: 1, customer: 'Alice', total: 99.99, status: 'shipped' },
{ id: 2, customer: 'Bob', total: 149.50, status: 'pending' }
]
};
// Convert to TOON
const toonData = encode(data);
// Send to LLM
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{
role: 'user',
content: `Analyze these orders:\n\n${toonData}`
}]
});
// Result: 60% fewer tokens, same data!
TOON is fully open source under MIT license. Contribute, report issues, or suggest improvements on GitHub.
Visit GitHubFull specification, API documentation, and examples to help you get the most out of TOON.
Read Docs