I run a small developer tools site, and the whole thing started with one annoyance: sending JSON arrays to GPT or Claude wastes a ridiculous amount of tokens on repeated keys.
Look at a typical API response:
[
{ "id": 1, "name": "Alice", "role": "admin", "active": true },
{ "id": 2, "name": "Bob", "role": "editor", "active": true },
{ "id": 3, "name": "Carol", "role": "viewer", "active": false }
]
Three records, and the keys id, name, role, and active appear three times each. Now imagine 500 records. You are paying your LLM provider to read the same four words 500 times.
TOON is a compact format that declares the keys once, then lists values row by row:
users[3]{id,name,role,active}: 1,Alice,admin,true
2,Bob,editor,true
3,Carol,viewer,false
Same data. On my test sets this cuts tokens by 30 to 60 percent depending on how repetitive the data is. The bigger the array and the shorter the values, the bigger the saving, because keys make up a larger share of the payload.
The honest limitations
It only helps with arrays of similar objects. Deeply nested or mixed-shape data saves little or nothing.
The model needs one instruction line, something like: the following block is a compact table representation of JSON. Modern models handle it fine, but do not skip the hint.
If your prompt is mostly instructions and only a little data, the saving will not matter. This is for people stuffing hundreds of records into context. The math
Say you push 10 million input tokens a month through GPT-4o at 2.50 dollars per million. If 60 percent of that is tabular JSON and TOON cuts it by 45 percent, you save around 6.75 dollars per million on that share, roughly 480 dollars a year. Not life changing at small scale, but it compounds fast at higher volume, and it also frees context window, which is sometimes worth more than the money.
I built a free converter that does JSON to TOON and back, shows a token estimate for both formats, and runs entirely in the browser: jsontoonpro.com. While building it I ended up adding about 50 other client-side tools (formatters, Base64, hash generators), but the TOON converter is still the reason the site exists.
Happy to answer questions about the format or share the test data I used for the percentages.
#llm #json #ai #webdev