How to use it
- Paste TOON on the left: a file, a prompt fragment, or a model’s response.
- Set TOON indent to match the input: 2 spaces (the default) or 4.
- Leave Strict lengths on to validate declared array lengths and row counts, or switch it off to decode partial data.
- Set Indent for the JSON output: 2 spaces, 4 spaces, tabs or Minify.
- Copy or download the JSON.
When decoding fails, the error panel shows the message and the line where the decoder stopped. Click Jump to error to put the cursor on that line.
Example
The sample input:
users[3]{id,name,role,active}:
1,Ada,admin,true
2,Linh,editor,true
3,Minh,viewer,false
team:
name: Platform
tags[2]: backend,infra
decodes to:
{
"users": [
{ "id": 1, "name": "Ada", "role": "admin", "active": true },
{ "id": 2, "name": "Linh", "role": "editor", "active": true },
{ "id": 3, "name": "Minh", "role": "viewer", "active": false }
],
"team": { "name": "Platform", "tags": ["backend", "infra"] }
}
(Shown compacted here — the tool pretty-prints with your chosen indent.)
Notice that 1, true and false become real JSON numbers and booleans, while unquoted words like Ada become strings.
When to use it
TOON usually shows up in LLM workflows: you send data to a model as TOON to save tokens, and ask it to answer in TOON as well. Decode the reply here to get JSON your code can use, check it in the JSON Formatter, or browse it in the JSON Viewer. The Reverse button sends the decoded JSON back to JSON to TOON — a quick way to confirm the data survives a round trip.
Reading TOON syntax
| TOON | Meaning |
|---|---|
key: value |
Object property, like YAML |
tags[2]: backend,infra |
Inline array of 2 primitive values |
users[3]{id,name}: |
Array of 3 objects; fields declared once, one row per object below |
"27\" Monitor" |
Quoted string, used when a value contains a delimiter, quote or leading/trailing space |
| Indentation | Nesting — child keys and rows are indented under their parent |
Strict mode catches truncated output
Models sometimes stop in the middle of a list. Because TOON declares the length up front, a truncated table is detectable. For example:
users[3]{id,name}:
1,Ada
2,Linh
fails in strict mode with Expected 3 tabular rows, but got 2 at line 3. With strict mode off, the same input decodes to the two rows that exist — useful for salvaging data, but make sure your code knows a row is missing.
In code
import { decode } from '@toon-format/toon';
const data = decode(toonText, { strict: true });
Wrap the call in try/catch and retry the request when decoding fails. To go the other way, use JSON to TOON. If a model returned JSON instead of TOON, JSON Repair can fix the common syntax problems.
Frequently asked questions
What does "Strict lengths" do?
TOON arrays declare their length, like users[3]. With Strict lengths on (the default), the decoder rejects input where the number of rows or items doesn't match, e.g. "Expected 3 tabular rows, but got 2". Turn it off to decode whatever rows are present.
Why would TOON from an LLM fail to decode?
The most common causes are a row count that doesn't match the declared length (often because the response was cut off), a row with more or fewer values than the header's field list, and inconsistent indentation.
Which indentation does the decoder expect?
Two spaces per level by default, which is what TOON encoders emit. If your file uses four spaces, set **TOON indent** to 4 before decoding.
Are large integers preserved?
Not above 2^53. The TOON decoder returns standard JavaScript numbers, so an ID like 9007199254740993 comes out as 9007199254740992, and the tool shows a warning naming the affected value. Quote such IDs as strings in TOON if you need every digit.
Is my data uploaded?
No. Decoding runs entirely in your browser with the open-source @toon-format/toon library — nothing is uploaded.
Last updated