Every key, quote and brace in a JSON prompt costs tokens. TOON (Token-Oriented Object Notation) is a format designed to send the same data in fewer of them.
Same data, two encodings
JSON (pretty-printed):
{
"users": [
{ "id": 1, "name": "Asha", "role": "admin" },
{ "id": 2, "name": "Daniel", "role": "editor" },
{ "id": 3, "name": "Mia", "role": "viewer" }
]
}
TOON:
users[3]{id,name,role}:
1,Asha,admin
2,Daniel,editor
3,Mia,viewer
The header users[3]{id,name,role} declares the array length and the field names once. Each row is then just values. With 1,000 users, JSON repeats "id", "name" and "role" 1,000 times; TOON writes them once.
How TOON encodes other shapes
service: checkout
replicas: 3
env:
LOG_LEVEL: info
REGION: eu-west-1
tags[3]: payments,critical,eu
- Objects use indentation and
key: value, like YAML. - Arrays of primitives go inline:
tags[3]: a,b,c. - Arrays of uniform objects become tables (the header + rows form above).
- Strings are quoted only when they need to be (commas, leading spaces, values that look like numbers or booleans).
Where TOON helps and where it does not
| Data shape | Likely savings vs compact JSON |
|---|---|
| Long arrays of objects with identical keys (rows from a DB, logs, products) | Large |
| Mixed config-style objects | Small to moderate |
| Deeply nested or irregular objects (different keys per item) | Little or none; can be larger |
| A handful of short values | Negligible |
Two caveats:
- Compare against minified JSON, not pretty-printed JSON. Removing whitespace alone (
JSON.stringify(data)with no indent) recovers a lot of the gap. - Accuracy matters more than tokens. Models have seen enormous amounts of JSON. Test whether answers over TOON input are as accurate as over JSON for your task before you switch.
Where JSON should stay
- Model outputs. Structured outputs (
output_config.formaton Claude,response_formaton OpenAI) enforce a JSON Schema and only produce JSON. See LLM structured outputs. - Tool calls. Tool inputs and results are JSON on every major API.
- Storage and APIs. TOON is a transport for prompts, not a file format for your systems.
A practical recipe
- Keep data as JSON everywhere in your system.
- For a large, table-like input (say, 500 order rows), encode it with a TOON library right before building the prompt.
- Count tokens both ways with your provider's token-counting endpoint.
- Run your eval on both encodings. Keep TOON only if it saves meaningful tokens and accuracy holds.
- Ask the model to reply in JSON, ideally with an enforced schema.
Alternatives worth trying first
- Minify the JSON. Often the biggest cheap win.
- Drop fields the model does not need.
- CSV for strictly flat tables. TOON's tables are close to CSV but also handle nesting.
- Prompt caching if the same large context is sent repeatedly; it cuts cost regardless of format.
Related
- JSON vs YAML: TOON borrows YAML's indentation.
- JSON vs JSONL: the format LLM batch and fine-tuning files use.