How to use it
- Paste JSON on the left. Invalid JSON is reported with the exact line and column.
- Choose a Delimiter for table rows: comma (the default), tab or pipe. Tab and pipe help when your values contain lots of commas.
- Set Indent to 2 or 4 spaces.
- Copy the TOON output into your prompt. The status bar shows the output length against minified JSON, e.g.
191 chars vs 307 minified JSON (−38%).
What the output looks like
The sample product list converts to:
products[4]{sku,name,price,stock}:
KB-01,Mechanical Keyboard,89.9,120
MS-02,Wireless Mouse,24.5,340
HD-03,USB-C Hub,39,75
MN-04,"27\" Monitor",249,18
currency: USD
updated: 2026-09-27
Reading it:
products[4]declares an array with 4 elements. That explicit length lets a model (or a strict decoder) notice truncated or missing rows.{sku,name,price,stock}lists the fields once, instead of repeating every key in every object like JSON does.- Each indented line is one row. Strings are quoted only when they need it, such as the value containing
". - Plain key/value pairs (
currency: USD) use YAML-style syntax.
When TOON helps — and when it doesn’t
TOON saves the most on uniform arrays of objects: API results, database rows, product catalogs, log records with a fixed shape. The column header replaces thousands of repeated keys.
It helps much less, or even hurts, when data is deeply nested or irregular. For example, this input:
{"a":{"b":{"c":[1,{"x":1},"s"]}},"items":[{"id":1},{"id":2,"extra":true}]}
falls back to TOON’s list form and comes out about 30% larger than minified JSON. The status bar shows this immediately, so you can decide per payload. The TOON authors make the same point: compact JSON often wins for deeply nested or non-uniform data, and plain CSV is smaller for purely flat tables.
Tips for LLM prompts
- Say what the format is. A short line such as “Data is in TOON format:
name[N]{fields}:followed by one row per item” helps models that haven’t seen it before. - Keep JSON in your code. Use TOON only as the prompt representation; parse model responses as JSON, or decode TOON with TOON to JSON.
- Flatten first if needed. If an array is almost uniform, removing rarely-used fields can make it eligible for the compact table form.
In code
import { encode, decode } from '@toon-format/toon';
const toon = encode(data, { delimiter: '\t' });
const back = decode(toon); // deep-equals data
Related tools: JSON to YAML for config files, and JSON to CSV when you only need a flat table.
Frequently asked questions
What is TOON?
TOON (Token-Oriented Object Notation) is a compact, human-readable encoding of the JSON data model designed for LLM prompts. It uses YAML-like indentation for nested objects and a CSV-like table form for arrays of objects that share the same fields.
Is the conversion lossless?
Yes for standard JSON data — objects, arrays, strings, numbers, booleans and null all round-trip, and you can check by pasting the output into TOON to JSON. When encoding, integers larger than 2^53 (such as 64-bit database IDs) are written exactly as they appear in your JSON instead of being rounded.
Does the saving shown equal token savings?
No. The status bar compares character counts against minified JSON. Token counts depend on the model's tokenizer, so treat the percentage as a guide and measure with your provider's token counter for exact numbers.
When should I not use TOON?
When the data is deeply nested or the objects in an array have different fields. The TOON authors note that compact JSON often wins for non-uniform structures, and that plain CSV is smaller for purely flat tables.
Is my data uploaded?
No. Encoding runs entirely in your browser using the open-source @toon-format/toon library — nothing is uploaded.
Last updated