If you’re even slightly deep into the world of agentic AI, you’ve probably seen it: blog after blog mentioning something called TOON. The posts were short. Some offered impressive claims like “cuts JSON token usage in half.” Others just mentioned it as a rising serialization format for LLMs, especially in agent-based workflows.
Curious but unsatisfied, I decided to take a different route. I didn’t just want to read about TOON, I wanted to build with it. I wanted to see what made it special, how it compares to formats like JSON and CSV, and where it actually shines. And of course, I wanted to share what I found in a way that makes it easier for you to understand too.
This blog is that story.
Agentic AI in One Paragraph
If you’re working with agentic AI framework…
If you’re even slightly deep into the world of agentic AI, you’ve probably seen it: blog after blog mentioning something called TOON. The posts were short. Some offered impressive claims like “cuts JSON token usage in half.” Others just mentioned it as a rising serialization format for LLMs, especially in agent-based workflows.
Curious but unsatisfied, I decided to take a different route. I didn’t just want to read about TOON, I wanted to build with it. I wanted to see what made it special, how it compares to formats like JSON and CSV, and where it actually shines. And of course, I wanted to share what I found in a way that makes it easier for you to understand too.
This blog is that story.
Agentic AI in One Paragraph
If you’re working with agentic AI frameworks like CrewAI, LangGraph, or AutoGen, you already know the basics: agents powered by LLMs collaborate, passing structured information between each other to complete tasks. Think of each agent like a focused worker, one might gather data, another might summarize it, and another might generate recommendations.
But here’s the catch: every time they exchange data, it costs tokens. And in LLMs, tokens mean time, money, and performance limits.
That’s where TOON comes in.
So... What Is TOON, Really?
TOON stands for Token-Oriented Object Notation. It’s a new serialization format that’s designed specifically for LLM communication. Like JSON, it can represent nested, structured data. But unlike JSON, it avoids all the extra syntax, no curly braces, no repeated field names, and no need for quotes around every string.
Here’s a side-by-side comparison to make that clearer:
A Simple JSON:
[
{"id": 1, "name": "Alice", "score": 85},
{"id": 2, "name": "Bob", "score": 92}
]
Same in TOON:
data[2]{id,name,score}:
1,Alice,85
2,Bob,92
TOON is compact, readable, and tailor-made for LLMs. But I wanted to know: how much better is it, really?
The POC I Built
Before diving into results, here are the exact two scripts used for benchmarking. These are available publicly so readers can clone and run them:
- Test 1 (Complex Nested JSON): https://github.com/trickste/toontoon/blob/main/toon_test_1.py
- Test 2 (Flat JSON): https://github.com/trickste/toontoon/blob/main/toon_test_2.py
These scripts serialize the same dataset into different formats and measure how many tokens each representation consumes when passed through an LLM.
To really understand TOON, I built a two-agent proof of concept powered by Ollama (LLaMA 3.1) running locally. The idea was simple:
- Agent 1 (Data Generator): produces structured data in Python
- Agent 2 (LLM Analyzer): consumes that data in various formats and explains it
But here’s the twist: I fed the data into Agent 2 using six different serialization formats:
- JSON
- JSON (Compact)
- YAML
- XML
- CSV
- TOON
And for each one, I measured:
- How many tokens the format used
- Whether the LLM could interpret it clearly
⚠️ I’ll be uploading both the flat and nested versions of the POC on GitHub. You’ll find the links at the end of this post.
How the Data Looks Across Formats
Below are simplified examples to help you visualize how flat and nested JSON convert into TOON.
Flat JSON Example
JSON
[
{"id": 1, "name": "Alice", "score": 85},
{"id": 2, "name": "Bob", "score": 92},
{"id": 3, "name": "Charlie", "score": 78}
]
TOON
data[3]{id,name,score}:
1,Alice,85
2,Bob,92
3,Charlie,78
Complex Nested JSON Example
JSON
[
{
"id": 1,
"name": "Alice",
"score": 85,
"contact": {"email": "alice@example.com", "phone": "123-456"},
"tags": ["math", "science"],
"projects": [
{"title": "AI Lab", "year": 2022},
{"title": "Robotics", "year": 2023}
]
},
{
"id": 2,
"name": "Bob",
"score": 92,
"contact": {"email": "bob@example.com", "phone": "789-012"},
"tags": ["physics"],
"projects": [
{"title": "Quantum Lab", "year": 2021}
]
}
]
TOON
data[2]{id,name,score,contact,tags,projects}:
1,Alice,85,{'email': 'alice@example.com', 'phone': '123-456'},['math','science'],[{'title':'AI Lab','year':2022},{'title':'Robotics','year':2023}]
2,Bob,92,{'email': 'bob@example.com', 'phone': '789-012'},['physics'],[{'title':'Quantum Lab','year':2021}]
This is where things get interesting. You can see immediately that for simple rows, TOON is incredibly compact... but as soon as nested structures appear, TOON begins embedding Python-like lists and dictionaries inside its rows.
The Results: Token Counts by Format
Test 1: Complex Nested Data (contacts, tags, projects)
| Format | Token Count |
|---|---|
| CSV | 58 |
| TOON | 118 |
| JSON Compact | 102 |
| YAML | 135 |
| XML | 178 |
| JSON | 203 |
Test 2: Simple Flat Data (id, name, score)
| Format | Token Count |
|---|---|
| CSV | 23 |
| TOON | 33 |
| JSON Compact | 38 |
| YAML | 51 |
| XML | 71 |
| JSON | 77 |
🧠 Key Takeaway: CSV Isn’t Always Enough
Wait... CSV is cheaper than TOON in both cases?
Yes, but there’s a catch.
CSV is great for flat data. But as soon as your data includes nested objects, lists, or hierarchies, CSV becomes... lossy. You end up flattening objects into strings. You lose type safety. You lose clarity.
In contrast, TOON maintains full structure, while being much leaner than JSON.
- JSON repeats every key
- XML doubles them with open and close tags
- YAML saves space but isn’t built for tabular rows
- TOON gives you schema + data, with nearly CSV-level efficiency
That’s why TOON is rising fast in agentic tools. It’s not about beating CSV, but about replacing JSON in places where token count actually matters.
What I Learned (And What You Can Try)
This POC taught me far more than just how different serialization formats compare. It revealed how LLMs actually behave when they are fed structured data, and why some formats may be popular even when they don’t always win the token race.
Here are the real lessons that stood out.
TOON shines when structure matters
If your data has any level of hierarchy, TOON keeps the meaning intact while still being much more compact than JSON. It lets you:
- preserve nested objects
- keep column-like readability
- maintain type hints
- avoid repeated keys
This balance explains why TOON is becoming a popular choice in agentic systems.
CSV gives the fewest tokens, but at a real cost
CSV had the lowest token counts in both tests. That part is true.
But CSV comes with limitations that make it hard to use in multi-agent AI workflows:
- it cannot represent nested structures
- lists and objects get flattened into strings
- type information is lost
- you cannot reliably reconstruct the original JSON
- LLMs sometimes misinterpret flattened mixed content
So CSV wins in raw token count, but loses the moment your agents need anything more than simple rows.
JSON Compact is a practical middle ground
Compact JSON performed far better than formatted JSON. It:
- keeps full structure
- removes all whitespace
- tokenizes efficiently
It is still more verbose than TOON for flat data, but more predictable for nested data.
TOON is optimized for LLM clarity, not just token savings
When LLMs read TOON, the schema line gives them:
- number of items
- field names
- expected structure
This helps models interpret the data more reliably than CSV or XML.
In real agent workflows, clarity often beats a small token savings.
Nested data changes everything
In the nested test, TOON did not produce the smallest token count because the inline lists and dicts added overhead. This showed a valuable insight:
TOON works best for uniform row-like structures. For deep nesting, compact JSON may be more efficient.
This is important because it means serialization choices should match your data shape, not simply rely on trends.
The real takeaway
Each format has strengths:
- CSV: smallest tokens, weakest structure
- TOON: great structure-to-token ratio, very LLM friendly
- JSON Compact: predictable, solid for nested data
- YAML: readable, moderate token usage
- XML: expressive but token-heavy
And the biggest thing we learned:
TOON is becoming popular not because it always produces the smallest token count, but because it gives you structure, compactness, and LLM-friendly clarity in one place.
If your agents need to share structured data and reason about it reliably, TOON is a strong contender.
Tools I Used
Here’s the stack I used for this POC:
- Python 3.10+
- Ollama running LLaMA3:latest locally
- tiktoken for token counting
- python-toon (fallback inline encoder included)
- CSV / JSON / YAML / XML modules
The agents are simple but modular, you can replace Agent 1 with an API call or Agent 2 with a more sophisticated analysis.
Final Thoughts
This POC showed that serialization shapes how agents think. TOON isn’t always the smallest, but it delivers a strong balance of structure and clarity for agentic workflows. Test different formats with your own data and see what your LLM responds to best.
Thanks for reading!