Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow.
TOON combines YAML's indentation-based structure for nested objects with CSV-style tabular forms for uniform data. Its sweet spot is uniform objects β same fields across items, whether in an array or keyed by ID β reaching CSV-like compactness while adding explicit structure that helps LLMs parse and validate data reliably. For deeply nested or non-uniform data, JSON may be more efficient.
Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input β a drop-in, lossless representation of the JSON you already have.
Tip
The TOON format is stable, but also an idea in progress. Nothing's set in stone β help shape where it goes by contributing to the spec or sharing feedback.
- Why TOON?
- Key Features
- When Not to Use TOON
- Benchmarks
- Installation & Quick Start
- CLI
- Using TOON with LLMs
- Ecosystem
- Documentation
- Media Type & File Extension
- π Full Specification
LLM tokens cost money β and JSON spends a lot of them on structure. A weather forecast in TOON:
location:
city: Berlin
country: DE
units: metric
alerts[2]: frost,wind
forecast[3]{day,temp{min,max},condition,rainChance}:
Mon,-2,4,snow,80
Tue,1,7,cloudy,20
Wed,3,11,sunny,5The same data as JSON β ~117 tokens against TOON's ~66:
{
"location": {
"city": "Berlin",
"country": "DE",
"units": "metric"
},
"alerts": [
"frost",
"wind"
],
"forecast": [
{
"day": "Mon",
"temp": {
"min": -2,
"max": 4
},
"condition": "snow",
"rainChance": 80
},
{
"day": "Tue",
"temp": {
"min": 1,
"max": 7
},
"condition": "cloudy",
"rainChance": 20
},
{
"day": "Wed",
"temp": {
"min": 3,
"max": 11
},
"condition": "sunny",
"rainChance": 5
}
]
}Three things are happening at once in the TOON above. Two are forms β one rendering of a value, picked automatically from the data's shape β and the third is a header feature:
alerts[2]: frost,windis inline form: a primitive array on its header line.forecast[3]{day,β¦}:is tabular form: the field list is declared once in the header, then one row per element.temp{min,max}inside that header is a nested field group: the uniform nestedtempobjects fold into the header while rows stay flat.
The third form is keyed tabular, for objects whose values are uniform objects β config maps, feature flags, records by ID. The colon after the length ([2:]) marks it, and each row carries its own key:
| JSON | TOON |
|---|---|
{
"environments": {
"production": { "region": "eu-central-1", "replicas": 6, "debug": false },
"staging": { "region": "eu-central-1", "replicas": 2, "debug": true }
}
} |
|
Anything that fits none of these β mixed types, non-uniform objects β falls back to the fourth form, list form: one - item per element, or a bare - for an empty object. Those four cover the shapes; the Format Overview covers the rest.
Tip
Try it on your own data β no install required:
cat data.json | npx @toon-format/cli --statsIt prints the TOON alongside what the conversion saved β on the weather forecast above, that's:
βΉ Token estimates: ~117 (JSON) β ~66 (TOON)
β Saved ~51 tokens (-43.6%)
- π Token-Efficient & Accurate: Matches JSON's retrieval accuracy with fewer tokens β see Benchmarks.
- π JSON Data Model: Encodes the same objects, arrays, and primitives as JSON with deterministic, lossless round-trips.
- π€οΈ LLM-Friendly Guardrails:
[N]declares how many rows,{fields}how wide β so truncated or malformed output can't slip through. - π Minimal Syntax: Uses indentation instead of braces and minimizes quoting, giving YAML-like readability with CSV-style compactness.
- π§Ί Tabular Forms: Uniform objects β in an array or under keys β declare the field list once, then stream one row each.
- π Multi-Language Ecosystem: Official implementations, plus dozens of community ports, all targeting one spec with a shared conformance test suite.
TOON excels with arrays of uniform objects. Reach for something else when:
- Structures are deeply nested or non-uniform (tabular eligibility β 0%) β compact JSON often wins outright.
- Arrays are semi-uniform (~40β60% eligibility) β savings shrink; stay on JSON if your pipeline already speaks it.
- Data is purely tabular β CSV is smaller. TOON's ~5β10% overhead buys declared lengths, field lists, and delimiter scoping, which is a reliability trade, not a size one.
- Latency dominates β some deployments (notably local or quantized models) process compact JSON faster despite the higher token count. Measure TTFT and total time on your own setup.
Benchmarks below quantify the token and accuracy trade-offs; latency is the one you have to measure yourself.
Two tracks, so every comparison is like-for-like:
- Mixed-Structure Track: Nested and semi-uniform datasets (TOON vs JSON, YAML, XML). CSV is excluded β it cannot represent these structures without lossy flattening.
- Flat-Only Track: Flat, fully tabular-eligible datasets, where CSV is a fair competitor.
Benchmarks test LLM comprehension across different input formats using 244 data retrieval questions on 4 models.
Show Dataset Catalog
| Dataset | Rows | Structure | CSV Support | Eligibility |
|---|---|---|---|---|
| Uniform employee records | 100 | uniform | β | 100% |
| E-commerce orders with nested structures | 50 | nested | β | 33% |
| Time-series analytics data | 60 | uniform | β | 100% |
| Top 100 GitHub repositories | 100 | uniform | β | 100% |
| Semi-uniform event logs | 75 | semi-uniform | β | 50% |
| Deeply nested configuration | 1 | deep | β | 0% |
| Valid complete dataset (control) | 20 | uniform | β | 100% |
| Array truncated: 3 rows removed from end | 20 | uniform | β | 100% |
| Extra rows added beyond declared length | 20 | uniform | β | 100% |
| Inconsistent field count (missing salary in row 10) | 20 | uniform | β | 100% |
| Missing required fields (no email in multiple rows) | 20 | uniform | β | 100% |
| Feature flags keyed by name | 40 | uniform | β | 100% |
| Contacts with nested address and plan groups | 50 | nested | β | 100% |
Structure classes:
- uniform: All objects have identical fields with primitive values
- semi-uniform: Mix of uniform and non-uniform structures
- nested: Objects with nested structures (nested objects or arrays)
- deep: Highly nested with minimal tabular eligibility
CSV Support: β (supported), β (not supported β would require lossy flattening)
Eligibility: Percentage of arrays and keyed maps that qualify for TOON's tabular forms (uniform records whose fields are primitives or uniform nested objects folded into nested field groups)
Each format ranked by efficiency (accuracy percentage per 1,000 tokens):
TOON ββββββββββββββββββββ 29.2 acc%/1K tok β 72.2% Β±2.8 acc β 2,474 tokens
JSON compact ββββββββββββββββββββ 23.8 acc%/1K tok β 69.0% Β±2.9 acc β 2,892 tokens
YAML ββββββββββββββββββββ 20.1 acc%/1K tok β 70.1% Β±2.9 acc β 3,487 tokens
JSON ββββββββββββββββββββ 16.6 acc%/1K tok β 71.4% Β±2.8 acc β 4,308 tokens
XML ββββββββββββββββββββ 14.4 acc%/1K tok β 70.7% Β±2.9 acc β 4,909 tokens
Efficiency score = (Accuracy % Γ· Tokens) Γ 1,000. Higher is better.
Tip
TOON achieves 72.2% accuracy (vs JSON's 71.4%) while using 42.6% fewer tokens.
Note
CSV is excluded from the ranking as it only supports 109 of 244 questions (flat tabular data only). While CSV is highly token-efficient for simple tabular data, it cannot represent nested structures that other formats handle.
Every format answers the same 109 flat-dataset questions per model, so CSV can be compared on equal footing here.
| Format | Accuracy | Correct/Total | Avg Tokens |
|---|---|---|---|
toon |
63.1% Β±4.5 | 275/436 | 1,994 |
csv |
62.2% Β±4.5 | 271/436 | 1,851 |
json-pretty |
60.3% Β±4.6 | 263/436 | 3,950 |
xml |
60.1% Β±4.6 | 262/436 | 4,516 |
yaml |
59.9% Β±4.6 | 261/436 | 3,270 |
json-compact |
58.0% Β±4.6 | 253/436 | 2,718 |
Accuracy across 4 LLMs on 244 data retrieval questions:
claude-haiku-4-5-20251001
β TOON ββββββββββββββββββββ 65.6% Β±5.9 (160/244)
JSON ββββββββββββββββββββ 63.5% Β±6.0 (155/244)
XML ββββββββββββββββββββ 62.3% Β±6.0 (152/244)
YAML ββββββββββββββββββββ 62.3% Β±6.0 (152/244)
JSON compact ββββββββββββββββββββ 61.9% Β±6.0 (151/244)
CSV ββββββββββββββββββββ 49.5% Β±9.2 (54/109)
gemini-3.6-flash
β TOON ββββββββββββββββββββ 69.3% Β±5.8 (169/244)
JSON ββββββββββββββββββββ 68.4% Β±5.8 (167/244)
YAML ββββββββββββββββββββ 67.6% Β±5.8 (165/244)
XML ββββββββββββββββββββ 65.2% Β±5.9 (159/244)
JSON compact ββββββββββββββββββββ 63.5% Β±6.0 (155/244)
CSV ββββββββββββββββββββ 57.8% Β±9.1 (63/109)
gpt-5.4-nano
XML ββββββββββββββββββββ 59.4% Β±6.1 (145/244)
JSON ββββββββββββββββββββ 57.4% Β±6.2 (140/244)
β TOON ββββββββββββββββββββ 57.0% Β±6.2 (139/244)
JSON compact ββββββββββββββββββββ 54.9% Β±6.2 (134/244)
YAML ββββββββββββββββββββ 54.5% Β±6.2 (133/244)
CSV ββββββββββββββββββββ 46.8% Β±9.2 (51/109)
grok-4.5
β TOON ββββββββββββββββββββ 97.1% Β±2.2 (237/244)
JSON ββββββββββββββββββββ 96.3% Β±2.5 (235/244)
XML ββββββββββββββββββββ 95.9% Β±2.6 (234/244)
YAML ββββββββββββββββββββ 95.9% Β±2.6 (234/244)
JSON compact ββββββββββββββββββββ 95.5% Β±2.7 (233/244)
CSV ββββββββββββββββββββ 94.5% Β±4.5 (103/109)
Note
Accuracy figures include Wilson 95% confidence intervals (Β±); when two formats' intervals overlap, the difference between them is not statistically meaningful. CSV answers only the 109 flat-dataset questions, so its per-model cells cover a smaller, easier population than the other formats.
Performance by dataset and question type
| Question Type | TOON | JSON | XML | YAML | JSON compact | CSV |
|---|---|---|---|---|---|---|
| Field Retrieval | 97.8% | 99.2% | 99.2% | 99.7% | 98.9% | 100.0% |
| Aggregation | 48.4% | 48.4% | 46.0% | 46.0% | 45.2% | 32.8% |
| Filtering | 38.0% | 41.1% | 37.5% | 40.1% | 38.0% | 33.3% |
| Structure Awareness | 90.3% | 84.0% | 84.0% | 79.2% | 78.5% | 82.8% |
| Structural Validation | 100.0% | 50.0% | 80.0% | 50.0% | 45.0% | 80.0% |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
64.6% | 2,336 | 106/164 |
toon |
62.8% | 2,537 | 103/164 |
json-compact |
62.2% | 3,919 | 102/164 |
yaml |
64.0% | 4,982 | 105/164 |
json-pretty |
62.2% | 6,326 | 102/164 |
xml |
61.0% | 7,286 | 100/164 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
json-compact |
70.7% | 6,875 | 116/164 |
toon |
71.3% | 7,344 | 117/164 |
yaml |
72.0% | 8,456 | 118/164 |
json-pretty |
71.3% | 10,842 | 117/164 |
xml |
74.4% | 12,180 | 122/164 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
64.2% | 1,408 | 77/120 |
toon |
63.3% | 1,595 | 76/120 |
json-compact |
59.2% | 2,351 | 71/120 |
yaml |
62.5% | 2,951 | 75/120 |
json-pretty |
65.0% | 3,678 | 78/120 |
xml |
62.5% | 4,386 | 75/120 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
toon |
57.6% | 9,017 | 76/132 |
csv |
54.5% | 8,726 | 72/132 |
json-compact |
53.8% | 11,650 | 71/132 |
yaml |
53.8% | 13,350 | 71/132 |
json-pretty |
55.3% | 15,350 | 73/132 |
xml |
53.8% | 17,304 | 71/132 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
json-compact |
56.7% | 4,793 | 68/120 |
toon |
60.8% | 5,814 | 73/120 |
json-pretty |
60.0% | 6,759 | 72/120 |
yaml |
55.0% | 5,798 | 66/120 |
xml |
50.8% | 7,668 | 61/120 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
json-compact |
91.4% | 562 | 106/116 |
yaml |
93.1% | 675 | 108/116 |
toon |
91.4% | 669 | 106/116 |
json-pretty |
94.8% | 918 | 110/116 |
xml |
94.0% | 1,007 | 109/116 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
toon |
100.0% | 566 | 4/4 |
json-compact |
100.0% | 772 | 4/4 |
yaml |
100.0% | 984 | 4/4 |
json-pretty |
100.0% | 1,259 | 4/4 |
xml |
0.0% | 1,441 | 0/4 |
csv |
0.0% | 473 | 0/4 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
100.0% | 408 | 4/4 |
toon |
100.0% | 498 | 4/4 |
xml |
100.0% | 1,229 | 4/4 |
json-pretty |
0.0% | 1,075 | 0/4 |
yaml |
0.0% | 841 | 0/4 |
json-compact |
0.0% | 660 | 0/4 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
100.0% | 547 | 4/4 |
toon |
100.0% | 644 | 4/4 |
xml |
100.0% | 1,663 | 4/4 |
json-pretty |
0.0% | 1,452 | 0/4 |
yaml |
0.0% | 1,135 | 0/4 |
json-compact |
0.0% | 893 | 0/4 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
100.0% | 470 | 4/4 |
toon |
100.0% | 563 | 4/4 |
json-compact |
75.0% | 767 | 3/4 |
xml |
100.0% | 1,432 | 4/4 |
yaml |
75.0% | 977 | 3/4 |
json-pretty |
75.0% | 1,251 | 3/4 |
| Format | Accuracy | Tokens | Correct/Total |
|---|---|---|---|
csv |
100.0% | 442 | 4/4 |
toon |
100.0% | 535 | 4/4 |
xml |
100.0% | 1,386 | 4/4 |
yaml |
75.0% | 941 | 3/4 |
json-pretty |
75.0% | 1,207 | 3/4 |
json-compact |
50.0% | 732 | 2/4 |
| Format | Accuracy | Tokens | Correct/Total |
|---|





