How to convert JSON to TOON (and why it saves tokens)
If you pass structured data to a language model, the format you use is not just cosmetic — it directly affects how many tokens you spend. JSON is convenient but heavy. Converting it to TOON keeps the same data while cutting the overhead, which means fewer tokens per prompt.
Where the tokens go in JSON
Take an array of records. In JSON, every single row repeats the field names, wraps each string in quotes, and adds braces and commas around everything:
{
"products": [
{ "sku": "A1", "name": "Pen", "price": 2 },
{ "sku": "A2", "name": "Pencil", "price": 1 },
{ "sku": "A3", "name": "Eraser", "price": 3 }
]
}
The words sku, name, and price appear three times each. Multiply that across a few hundred rows and a large share of your tokens is spent on field names you only needed to state once.
How TOON trims it
TOON declares the fields one time as a header, then lists just the values for each row:
products[3]{sku,name,price}:
A1,Pen,2
A2,Pencil,1
A3,Eraser,3
The data is identical. The repeated keys, most of the quotes, and the structural braces are gone. On real arrays of records, that routinely cuts the character count — and the token count that follows from it — by a meaningful margin. The bigger and more repetitive the dataset, the larger the saving.
Rule of thumb: the more rows that share the same fields, the more TOON saves. A single object barely changes; a long list changes a lot.
Getting TOON into your prompt
You do not need a library or a script. Run your JSON through the JSON to TOON converter, then copy the output straight into the spot where your data block goes in the prompt. Because it runs in your browser, even sensitive data stays on your machine, and the TOON to JSON converter reverses it whenever you need standard JSON back.
Open JSON to TOON
A few practical tips
- Convert the data closest to the model — keep JSON in your pipeline, switch to TOON only at the prompt boundary where tokens matter.
- Save the most with large, uniform arrays; do not bother for tiny payloads.
- Always be able to convert back. Keeping a TOON to JSON step handy means nothing is locked in.
New to the format? Start with what TOON is and how it looks.