TOON vs JSON
TOON (Token-Oriented Object Notation) is a compact text format for the same data JSON represents, designed to make structured data cheaper to put in an LLM prompt. It writes arrays of similar objects as a table with the field names stated once, and uses indentation instead of braces. The short answer to "is it better?": TOON clearly beats JSON on large uniform lists, but against minified JSON it can be bigger for nested or irregular data. The numbers below show both cases.
The same data in JSON and TOON
Three orders as JSON:
{
"orders": [
{ "id": 1001, "customer": "Ada", "status": "shipped", "total": 59.9 },
{ "id": 1002, "customer": "Linus", "status": "pending", "total": 12.5 },
{ "id": 1003, "customer": "Grace", "status": "shipped", "total": 140 }
]
}And as TOON:
orders[3]{id,customer,status,total}:
1001,Ada,shipped,59.9
1002,Linus,pending,12.5
1003,Grace,shipped,140The header orders[3]{id,customer,status,total}: says there are 3 items and names the fields once; each following line is one item. JSON repeats "id", "customer", "status", and "total" for every order, plus the braces and quotes around them. Convert your own data with the JSON to TOON converter.
Real token counts
We encoded three typical payloads with the official TOON encoder and counted tokens with the GPT-4o tokenizer (o200k):
| Data | Pretty JSON | Minified JSON | TOON | TOON vs minified |
|---|---|---|---|---|
| 50 uniform orders (5 fields each) | 2,157 | 1,203 | 805 | 33% smaller |
| Nested service config | 183 | 93 | 119 | 28% larger |
| 20 users with varying fields | 710 | 362 | 470 | 30% larger |
Two things stand out. First, every TOON result is far smaller than pretty-printed JSON, which is where most "TOON halves your tokens" claims come from. Second, if you already send minified JSON, TOON only wins when the data is a uniform table; for nested or irregular objects, indentation costs more tokens than JSON's punctuation. With a tab delimiter, the orders example improved slightly further, to 36% smaller than minified JSON.
Side-by-side comparison
| Aspect | JSON | TOON |
|---|---|---|
| Purpose | Universal data interchange | Compact LLM prompt input |
| Arrays of objects | Keys repeated on every item | Table: keys once, one row per item |
| Nesting | Braces and brackets | Indentation |
| Strings | Always quoted | Quoted only when needed |
| Array lengths | Implicit | Explicit ([3]), helps models and validation |
| Tooling | Built into every language | Libraries for a growing set of languages |
| Best for | APIs, storage, model output | Large uniform lists in prompts |
When to use TOON
- You put large lists of similar records into prompts: query results, product catalogs, logs, analytics rows.
- Token cost or context-window space is a real constraint.
- You control the prompt pipeline and can convert JSON to TOON just before sending.
When to stay with JSON
- The data is deeply nested or each object has different fields: minified JSON is likely smaller.
- You need the model to produce structured output: use JSON with a schema.
- The data goes anywhere other than an LLM: APIs, storage, and other tools all expect JSON.
The practical approach is to measure. Paste a real payload into the converter, compare against minified JSON, and count tokens before changing your prompts.
Related tools
- JSON to TOON: convert both ways and count GPT-4o tokens.
- JSON Minifier: the baseline TOON should beat.
- JSONL vs JSON: the other format you meet in LLM work.
- JSON vs YAML: TOON borrows YAML's indentation.
Frequently asked questions
What is TOON format?
TOON (Token-Oriented Object Notation) is a compact, human-readable encoding of the JSON data model built to reduce the number of tokens structured data costs in an LLM prompt. It uses indentation for nesting (like YAML) and a table layout for arrays of uniform objects (like CSV), declaring field names once instead of on every item.
Is TOON better than JSON?
Only for some data. In our measurements with the GPT-4o tokenizer, TOON was 33% smaller than minified JSON for a list of 50 uniform orders, but about 30% larger than minified JSON for nested config and for objects with varying fields. Against pretty-printed JSON, TOON was always smaller.
Does TOON save tokens with every model?
Token counts depend on each model's tokenizer, so savings differ between models, but the pattern holds: TOON saves the most on large uniform arrays, where JSON repeats every key on every item. Measure your own payloads with the JSON to TOON converter, which counts GPT-4o tokens.
Can LLMs read TOON?
Yes. TOON is plain text with explicit array lengths and field headers, and the TOON project reports comparable or slightly better retrieval accuracy than JSON in its benchmarks. As with any format, test it on your own task before switching production prompts.
Should LLMs output TOON?
Usually not. TOON is designed for input. For model output, JSON with a schema (structured outputs, function calling) is better supported by every provider and parser. A common pattern: keep JSON in your code, send TOON in the prompt, ask for JSON back.
Is TOON lossless?
Yes. TOON encodes exactly the JSON data model, so JSON converted to TOON and back is identical.