TOON vs JSON for LLM Prompts: Token Counts on Real CMS Data
TOON vs JSON on real CMS data: TOON cut tokens 18% on a flat list of 76 articles but added 22% on nested schemas. When each one wins in LLM prompts.
TOON uses fewer tokens than JSON when your data is a flat list of objects that all share the same keys. On deeply nested data, compact JSON often wins. We tested both on real data from our own CMS. On a list of 76 articles, TOON used 18.4% fewer tokens than compact JSON. On our nested template schemas, TOON used 22.2% more.
So TOON vs JSON isn't a format war. It's a question of data shape. This post shows our numbers, explains what TOON is, and covers when the switch is worth it in an LLM prompt or an MCP tool result.
What is TOON?
TOON stands for Token-Oriented Object Notation. Its GitHub repo calls it "a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow."
The key words are "the JSON data model." TOON holds the same things JSON holds: objects, arrays, strings, numbers, booleans, and null. You can convert JSON to TOON and back with no loss. We checked this on all three of our test sets, and every round trip matched byte for byte.
TOON is MIT licensed and led by Johann Schopplich. The spec is still a working draft. Version 1.0 landed on October 28, 2025, and the current draft is v4.4, dated October 8, 2026. Expect it to keep moving.
What does TOON look like?
TOON mixes two ideas. Nested objects use YAML-style indentation. Arrays of same-shape objects become a table: one header row with the field names, then one row per item.
Here are the first rows of our article list in TOON:
articles[76]{id,title,slug,pillar,type,status}:
6aac66067579a4238be265d9,"Draftbase vs TinaCMS: Content Modeling",draftbase-vs-tinacms,content-modeling,vs,draft
6aac65e07579a4238be265d8,"Draftbase vs Payload: Content Modeling",draftbase-vs-payload,content-modeling,vs,draft
The [76] says how many rows to expect. The {...} lists the fields once. In JSON, every one of those 76 rows repeats all six keys, plus quotes, colons, and braces. That repetition is where TOON saves its tokens.
When the data isn't a table, TOON falls back to indented key-value lines and list items. That's where the savings shrink or flip.
How we tested TOON vs JSON
We used three sets of real data from the Draftbase CMS that runs this site:
- Article list. 76 published and draft articles, each with six short fields: id, title, slug, pillar, type, and status. Flat and uniform.
- Template schemas. The field definitions for our three content templates. Nested objects, arrays of fields, and optional keys that some fields have and others don't.
- FAQ items. 15 question and answer pairs. Uniform, but each value is a full sentence of prose.
Each set was written five ways: pretty JSON with 2-space indent, compact JSON with no spaces, TOON from @toon-format/toon 4.4.0, YAML from js-yaml 5.5.0, and CSV where the data was flat. We counted tokens with tiktoken using the o200k_base encoding, the same one TOON's own benchmarks use.
TOON vs JSON: our token counts
| Data set | Pretty JSON | Compact JSON | YAML | TOON | CSV |
|---|---|---|---|---|---|
| 76 articles (flat) | 5,888 | 4,228 | 4,843 | 3,449 | 3,291 |
| 3 templates (nested) | 1,308 | 775 | 959 | 947 | n/a |
| 15 FAQs (prose) | 892 | 768 | 780 | 712 | 691 |
Against compact JSON, TOON's change was:
- Flat article list: 18.4% fewer tokens.
- Nested templates: 22.2% more tokens.
- Prose FAQs: 7.3% fewer tokens.
Against pretty JSON, TOON won all three, by 41.4%, 27.6%, and 20.2%. That's the comparison most TOON headlines use. But almost nobody should send pretty JSON to a model. Indentation is pure overhead to a tokenizer. Compact JSON is the fair baseline.
Why does TOON lose on nested data?
Look at what compact JSON drops. No spaces, no newlines, no indentation. Just braces, quotes, and keys.
TOON can't do that for nested data. Indentation is its syntax. Every level of depth adds leading spaces to every line, and each field goes on its own line. For our template schemas, that came out 22.2% larger than compact JSON. YAML, which works the same way, was 23.7% larger.
The other issue is shape. TOON's table form needs every row to have the same fields. Our template fields don't. Some have required, some have isSlug, some have options. So TOON can't use a table and writes each field as a block instead.
TOON's own docs agree. The README says its sweet spot is uniform arrays of objects. For deeply nested or non-uniform data, it says compact JSON is often more efficient. Their benchmark shows the same pattern. TOON was 5.6% larger than compact JSON on nested e-commerce orders, and 6.7% larger on deep config.
Why does prose shrink the gap?
Our FAQ set is uniform, so TOON used its table form. It still only saved 7.3% over compact JSON.
The reason is simple. Most of the tokens are the answers themselves. A sentence costs about the same in any format. TOON only trims the structure around it, and with long values, the structure is a small share of the total.
This matters for CMS content. A blog post is mostly prose. The title and slug are small. The body is thousands of tokens. Switching the wrapper format won't change much.
What does change the count is escaping. A JSON string can't hold a raw newline or a bare quote, so a long MDX body gets \n and \" all through it. We took three MDX posts and measured them raw, then as JSON strings. The JSON versions used 6.4%, 7.3%, and 9.2% more tokens. That's often a bigger win than the TOON vs JSON choice.
Does TOON make models more accurate?
Not by a margin you can count on. TOON's own benchmark reports 72.2% accuracy with 42.6% fewer tokens, against 71.4% for JSON. The test asks models questions about data passed in each format.
Those two accuracy numbers are close. The README itself notes that overlapping confidence intervals mean the gaps aren't statistically meaningful. The 42.6% token figure is also measured against formatted JSON. Against compact JSON, their own tables put TOON within about 2% on mixed data, and larger on nested sets.
There's one more limit. TOON's counts use an OpenAI tokenizer. Claude, Gemini, and Llama use their own. A format that saves 18% in o200k_base may save more or less elsewhere. We didn't test other tokenizers either, so treat our numbers the same way.
The fair reading is this: TOON saves real tokens on tables, and it doesn't seem to hurt accuracy. It isn't proven to help it.
TOON vs CSV: why not just use CSV?
On our flat article list, CSV beat TOON by 4.6%. On the FAQs, by 2.9%. TOON's own benchmark shows the same: CSV was 5.9% smaller on flat data.
So why use TOON at all? Because CSV only does tables. It has no nesting, no types, and no way to say "this field is a list." Real data has a table in one spot and a nested object in another. TOON handles both in one format. It also states the row count up front, which helps a model notice a cut-off list.
If your data is a pure table and will stay one, CSV is fine. If it mixes shapes, TOON is the more honest fit.
When should you use TOON in an LLM prompt?
Use this as a rough guide:
| Your data | Best format |
|---|---|
| Long list, same keys, short values | TOON or CSV |
| Mixed: a table plus some nesting | TOON |
| Deeply nested config or schemas | Compact JSON |
| Mostly prose, like articles | Raw text or MDX, not escaped JSON |
| Anything you send to a program | JSON |
Two more rules from testing. First, measure your own data with your own model's tokenizer before you switch. Shapes vary more than you'd guess. Second, keep JSON at the edges. Your APIs, webhooks, and storage should still speak JSON. Convert to TOON only at the point where you build the prompt.
How Draftbase formats CMS data for models
We hit this question building the Draftbase MCP server. Our answer was neither JSON nor TOON for entries.
When an agent calls get_entry or list_entries, it gets each entry as an MDX document. The short fields sit in front matter at the top. Each rich text field follows as a raw MDX section, marked with a <!-- field: key --> comment. So the body is never JSON-escaped. The model reads Markdown the way it was written.
Lists stay small on purpose. list_entries cuts long field values to 300 characters, and a fields option returns only the keys you ask for. An agent can scan 100 titles cheaply, then call get_entry for the one it needs.
Template schemas come back as JSON. They're small, nested, and read by code as often as by models. Our test above says compact JSON is the right call there.
If you want an agent to read and edit your content, how to let an AI agent edit content in your CMS walks through the setup. For the wider case on shaping content for models, see structured content for LLMs and AI agents.
Conclusion
TOON vs JSON comes down to the shape of your data. On a flat list of 76 articles, TOON cut tokens by 18.4% versus compact JSON. On nested schemas, it added 22.2%. On prose, the format barely matters, but JSON escaping costs 6% to 9%. Accuracy gains are too small to count on.
So use TOON for tables in prompts, compact JSON for nested data, and raw text for prose. Draftbase's MCP server already follows that split: MDX for content, JSON for schemas, and trimmed lists. The Hobby plan is free. See pricing to connect your own agent.
| Option | Verdict | Pros | Cons |
|---|---|---|---|
| TOON | Best for flat, same-shape lists inside LLM prompts. Skip it for nested data. |
|
|
| JSON | The default for APIs, storage, and nested data. Send it compact, never pretty, to a model. |
|
|
Ship content that's built to be found
Draftbase generates schema, structured data, and a fast MDX editor for every post.
Frequently asked questions
Is TOON better than JSON for LLMs?
Only for flat lists with the same keys. In our test, TOON used 18.4% fewer tokens than compact JSON on 76 articles, but 22.2% more on nested schemas.
What is TOON format?
TOON is Token-Oriented Object Notation. It holds the same data as JSON, but writes same-shape arrays as a table with one header row to save tokens.
Does TOON improve LLM accuracy?
Not by a clear margin. TOON's own test shows 72.2% accuracy, and JSON got 71.4%. Its README says the gap is too small to count.
Is TOON smaller than CSV?
No. CSV was 4.6% smaller than TOON on our flat article list. TOON's edge is that it also handles nested data, which CSV can't.
Should I convert my API to TOON?
No. Keep JSON for APIs, webhooks, and storage. Convert to TOON only when you build a prompt, and only for table-shaped data.
Working with this hands-on? Draftbase also has a free mcp inspector.