Choose language

JSON to TOON Converter

Convert JSON into compact TOON notation to cut LLM token usage, with key folding, delimiter options, and structure-preserving output.

Mehmet Demiray Published Updated
Share
Number of spaces per nesting level
Character used between values in tabular rows
Collapse single-key chains into dotted paths

What is TOON Format

TOON, short for Token-Oriented Object Notation, is a compact data format built to carry the same information as JSON while using far fewer tokens. It drops the punctuation that JSON repeats on every line, including most quotation marks, braces, brackets, and commas, and relies on indentation and simple delimiters to express structure instead. The result reads cleanly and stays machine-parseable, but it costs much less when fed into a large language model.

The practical difference shows up in AI workflows. JSON spends tokens on syntax that the model does not need to understand your data, and those tokens add up across long prompts and large arrays. TOON keeps the keys, values, and nesting that actually matter and removes the rest. For developers passing structured context to ChatGPT, Claude, or any token-billed API, that trimming can reduce payload size by a wide margin while keeping the meaning of every field intact.

How the Conversion Works

The converter parses your JSON into an object tree, then re-encodes that tree in TOON. Nesting becomes indentation, repeated keys across an array can be folded into a single header row, and the verbose separators JSON requires are replaced with lightweight delimiters. Because the transformation is structural rather than lossy, every key and value survives the round trip.

Key folding is where most of the savings come from. When you convert an array of objects that share the same fields, TOON can list those field names once and then stream the rows beneath them, much like a table. You can also pick the delimiter that suits your data, which matters when values contain commas or spaces. Compared with the original JSON, the TOON output is typically a fraction of the size, and tighter input means lower token counts. Paste your JSON, choose your options, and the converted TOON appears ready to copy.

When to Use TOON

TOON earns its place anywhere token count or byte size is a real cost. The clearest case is LLM prompting: when you inject configuration, records, or context into a model, TOON lets you fit more data into the same window and pay less per call. Long arrays of similar objects benefit the most, since key folding collapses the repetition that bloats JSON.

It also works well as a human-readable compact format. Configuration files written in TOON stay easy to scan because the indentation mirrors the structure, yet they avoid the visual noise of stacked brackets and trailing commas. For data transfer where bandwidth or storage is tight, the smaller footprint helps without forcing you into a binary format you cannot read or debug by eye. Teams that pass repeated context to a model on every request feel the savings most, since each trimmed call compounds across thousands of prompts. When you need the data back in standard form, the TOON to JSON Converter reverses the process without losing any fields. For comparison with a more familiar human-friendly format that trades some compactness for readability, see the JSON to YAML Converter.

TOON Compared to JSON

JSON is the default for APIs because it is universal and unambiguous, but that universality comes with overhead. Every string is quoted, every object is wrapped in braces, and every item is comma separated, so the same data repeats its scaffolding over and over. TOON keeps the data and discards most of the scaffolding.

A short example shows the gap:

Aspect JSON TOON
Quotes on keys required dropped
Brackets and braces required implied by indentation
Repeated array keys per object folded once
Typical token count baseline noticeably lower

The trade-off is reach. JSON is parsed everywhere, while TOON is purpose-built for token-sensitive contexts. If you need broad interoperability, keep JSON at the boundaries of your system and convert to TOON only where tokens are billed. If you simply want cleaner, validated JSON first, run it through the JSON Formatter before converting.

Getting Accurate Conversions

Accurate TOON output starts with valid JSON. If your source has a trailing comma, a missing quote, or mismatched braces, the parser cannot build a reliable tree, and the converted result will be incomplete. Validating or formatting the input first removes that risk and makes the conversion deterministic.

Pay attention to your delimiter choice when values themselves contain the delimiter character. Picking a separator that does not appear inside your data keeps each field cleanly bounded and avoids ambiguity in the output. For arrays meant to be folded, confirm that the objects share a consistent set of keys, since uniform records fold most efficiently and irregular ones fall back to a longer form. After converting, a quick read of the TOON confirms that the nesting matches your original structure. Treat TOON as the optimized form you send to a model, and keep the canonical JSON as your source of truth.

The ones we answer the most.

What is TOON and how does it differ from JSON?

TOON, or Token-Oriented Object Notation, holds the same structured data as JSON but expresses it with far less punctuation. Where JSON uses quotes, braces, brackets, and commas on every line, TOON uses indentation and light delimiters instead. The data and nesting are identical, so the difference is in how compactly the structure is written, which is what lowers the token count.

Can I convert TOON back to JSON?

Yes. The conversion preserves every key, value, and level of nesting, so the data round-trips without loss. To go the other direction, use the TOON to JSON Converter, which reads TOON and rebuilds standard JSON. A common pattern is to store canonical JSON, convert to TOON only when sending data to a model, and convert back whenever a tool expects ordinary JSON.

How much smaller is TOON compared to JSON?

The savings depend on your data, but arrays of similar objects shrink the most because key folding lists shared field names just once. By removing repeated quotes and separators, TOON commonly cuts token usage by a large share of the original. Flat or highly irregular data saves less, since there is less repetition to fold away.

How does TOON compare with YAML and TOML?

YAML and TOML are also human-readable alternatives to JSON, but they were designed mainly for configuration clarity rather than token efficiency. TOON specifically targets minimal token count for LLM prompts, using key folding to collapse repetitive arrays in a way those formats do not. If your goal is readable config, YAML or TOML are fine; if your goal is fewer tokens in a prompt, TOON is the better fit.

Does converting to TOON change my data?

No. The converter only changes how the data is written, not the data itself. Keys, values, types, and nesting are all carried across unchanged. It rewrites the syntax into a more compact form, so the meaning of every field stays exactly the same.

What should I check before converting?

Make sure your JSON is valid first, since a parser cannot reliably convert malformed input. Running it through a formatter to confirm structure is a good habit. Also choose a delimiter that does not appear inside your values, so each field stays clearly bounded in the TOON output.