Overview
Introduction
Every token in a prompt sent to an LLM costs money and counts against a context window, and JSON's punctuation, quotes around every string, braces around every object, repeated field names in every element of an array of records, is punctuation a tokenizer often can't compress away. TOON re-encodes the same data using indentation and a CSV-style tabular form for repetitive arrays instead, aiming to say the same thing in fewer tokens.
This tool performs that conversion entirely in the browser: paste JSON, get TOON text back, ready to paste into a prompt or store as a smaller cached payload.
What Is JSON to TOON?
TOON (Token-Oriented Object Notation) is a text serialization format for the same data model JSON represents (objects, arrays, strings, numbers, booleans, null), designed around minimizing token count when the text is going to be read by an LLM rather than parsed by a traditional program.
Structurally, it looks like a hybrid of YAML and CSV: nesting is expressed through 2-space indentation the way YAML does, but an array of same-shaped objects gets a single header line naming the fields once, followed by one comma-separated row per element, the way a CSV file would represent a table. Arrays of primitives are collapsed to a single inline line with a bracketed count.
Because indentation and the `[N]` counts carry structural meaning, TOON is markedly less forgiving of formatting mistakes than JSON is; it trades some of JSON's redundant self-description for a more compact representation.
How JSON to TOON Works
The converter parses your JSON and walks it recursively. Every object becomes `key: value` lines, one per key, indented two spaces per nesting level; a nested object's own key line ends with just `key:` and its children follow indented one level deeper.
Arrays are handled by shape: an array of only primitives becomes one inline line (`key[N]: v1,v2,v3`); an array where every element is an object with the exact same set of keys becomes the tabular form (`key[N]{field1,field2,...}:` plus one CSV-style row per element); anything else, a non-uniform array of objects, or an array mixing primitives, objects, and nested arrays, falls back to a `key[N]:` header followed by `- `-prefixed list entries, each rendered using these same rules.
Scalar values are left bare unless they'd be ambiguous: a value containing a comma, colon, bracket, brace, `#`, or newline, or one that looks like `true`/`false`/`null`/a number when it's actually meant as a literal string, gets wrapped in double quotes, with any internal double quote doubled rather than backslash-escaped. The root value, if it's an object, is emitted directly with no wrapping key; a root array is emitted the same way with the `key` part simply omitted.
When To Use JSON to TOON
Use it whenever you're about to paste a sizeable JSON payload, an API response, a database query result, a config file, into an LLM prompt and want to reduce the token cost without hand-summarizing or dropping fields.
It's especially worthwhile for arrays of same-shaped records (a list of users, orders, log entries): that's exactly the case TOON's tabular form is built for, and where the savings versus repeating JSON's `{"field":value,...}` per element are largest.
Often used alongside JSON to YAML Converter, JSON Minifier and JSON Schema Generator.
Features
Advantages
- Reduces token count for the same data, which lowers prompt cost and leaves more of the context window for everything else.
- The tabular form for uniform arrays of objects avoids repeating field names per element, unlike JSON.
- Runs entirely client-side; your data never leaves the browser during conversion.
- Deterministic and lossless for standard JSON values: the same input always converts to the same output, and no data from a well-formed JSON document is dropped.
Limitations
- TOON is not a drop-in replacement for JSON as a data-interchange or config format; it depends on precise indentation the way YAML does, with none of JSON's redundant closing punctuation to help a parser recover from a formatting mistake.
- This tool only converts JSON to TOON, not the reverse; consuming TOON output programmatically requires a TOON-aware decoder in your target language, which this tool doesn't provide.
- The tabular form only triggers when an array's objects share the exact same key set and every field value is a primitive; arrays of objects with even slightly different shapes fall back to the more verbose list form.
- Token savings depend on your data's shape: a JSON document that's already mostly short keys and few repeated structures will see smaller gains than a large array of same-shaped records.
JSON vs. TOON for an array of 100 same-shaped user records
| JSON | TOON | |
|---|---|---|
| Field names repeated per element | Yes, once per object | No, once in the header row |
| Quoting | Every string quoted | Only ambiguous strings quoted |
| Parseable by a standard library | Yes, `JSON.parse` | No, needs a TOON-aware decoder |
| Best for | Data interchange, configs, storage | LLM prompt payloads |
Examples
Best Practices & Notes
Best Practices
- Reach for TOON specifically for the prompt payload itself, not for your application's internal data interchange, where JSON's universal tooling support still wins.
- Favor arrays of same-shaped objects where possible in the data you're about to convert; that's where TOON's tabular form produces the largest token savings versus JSON.
- If an LLM needs to produce TOON back as output, show it a worked example in the prompt first. Unlike JSON, most models haven't seen as much TOON in training and benefit from an explicit pattern to follow.
- Don't assume TOON round-trips through a JSON parser; treat it as a one-way, prompt-bound encoding unless you also have a TOON decoder in your pipeline.
Developer Notes
The tabular form requires every array element to be a plain object with the exact same key set and every field value to be a JSON primitive (string, number, boolean, or null); a field holding a nested object or array forces the whole array into the list fallback, since a single CSV-style row can't represent per-element nested structure. Quoting follows CSV convention (doubled internal quotes) rather than JSON's backslash-escaping, and object/array keys themselves are emitted unquoted on the assumption they're simple identifiers; a key containing a colon or other TOON-significant character isn't separately quoted by this converter.
JSON to TOON Use Cases
- Shrinking a large JSON API response before pasting it into an LLM prompt to save context window and cost.
- Formatting a batch of same-shaped records (orders, log lines, search results) for an LLM to summarize or analyze.
- Reducing token cost for JSON that gets sent repeatedly in similar shape across many prompts.
- Producing a more human-skimmable view of an array of records than raw JSON, as a side benefit of the tabular form.
Common Mistakes
- Hand-editing TOON output and breaking its indentation, which (unlike JSON) has no closing braces to make the mistake obvious.
- Expecting a JSON parser to read TOON directly; it can't, since TOON isn't a JSON syntax variant.
- Assuming every array of objects will use the compact tabular form; if the elements don't share an identical key set, it won't.
Tips
- Check the output for `[N]:` list-form headers (rather than `[N]{...}:`) as a quick sign that an array's objects don't share a uniform shape; normalizing the source data first can shrink the token count further.
- Pair with the JSON Formatter to first inspect and clean up a JSON payload before converting it to TOON.
- For very large payloads, convert a representative subset first to confirm the token savings are worth adopting before switching an entire pipeline over.