JSON to TOON
Convert JSON to token-saving TOON and back for LLM prompts
About JSON to TOON
Encodes JSON as TOON (Token-Oriented Object Notation, spec v4.1) and decodes it back, with comma, tab or pipe delimiters, 2- or 4-space indentation and optional strict validation when decoding. A table compares characters and estimated tokens with minified and pretty-printed JSON. Uniform arrays of objects become compact tables, while deeply nested configs can end up larger than minified JSON, so measure before switching formats in prompts.
Category: AI Tools.
Frequently asked questions
When does TOON use fewer tokens than JSON?
▾
With uniform arrays of objects: TOON declares the field names once in a header such as users[2]{id,name}: and then writes one row of values per item. In our measurements, 50 flat records came out about half the size of minified JSON, while a deeply nested config was about 27% larger, because indentation costs more characters than braces.
Is the conversion lossless?
▾
For JSON data, yes: decoding the TOON returns the same values, and strings that look like numbers, booleans or null, such as '123' or 'true', are quoted so they stay strings. The exceptions are minor: an empty object encodes to an empty document, -0 becomes 0, and integers beyond 2^53 already lose precision when the JSON is parsed.
Which delimiter should I pick?
▾
Comma is the default and the easiest to read. Pipe avoids quoting values that contain commas, such as addresses, and tab can tokenize more cheaply in some models. The delimiter is declared in each array header, so TOON to JSON detects it automatically.
How accurate is the token comparison?
▾
It is an estimate: characters divided by four, rounded up, not a real tokenizer, so use it to compare formats rather than to predict a bill. Both the conversion and the count run locally in your browser, and real counts vary by model, especially for tabs, long numbers and non-English text.