Digital ToolPad.

Runs 100% in your browser

Your data never leaves your device. zero uploads.

TOON format converter for LLM prompts

JSON to TOON Converter with Token Comparison

TOON (Token-Oriented Object Notation) is a compact text format that holds the same data as JSON but writes arrays of similar objects as tables, so an LLM prompt needs fewer tokens. Paste JSON or open a .json file to convert it, compare exact token counts for TOON, minified JSON and pretty JSON, and convert TOON back to JSON with strict validation. It all runs in your browser.

How it works

Valid JSONRound trip checked: the TOON decodes back to identical data.

1,230 chars, 59 lines

Conversion and token counting run in your browser. Nothing is uploaded.

Token count: TOON vs JSON

Exact counts with o200k_base

  • TOON144 tokens
  • Minified JSON209 tokens
  • Pretty JSON (2 spaces)360 tokens

TOON uses 60% fewer tokens than pretty JSON and 31% fewer than minified JSON. Send the TOON.

Shape: 1 table (6 rows), 0 list arrays, 0 inline arrays. Tables are where TOON saves tokens; list arrays cost about as much as YAML.

What is TOON format?

TOON, short for Token-Oriented Object Notation, is an open format for passing structured data to large language models. It encodes the JSON data model (objects, arrays, strings, numbers, true, false and null) without loss, so you can convert JSON to TOON and back and get the same values. The specification is maintained by the toon-format project on GitHub, currently at version 4.4, with official libraries for TypeScript and Python.

TOON combines two familiar ideas. Nested objects use YAML-style indentation instead of braces. Arrays of objects that share the same keys become a table: the field names appear once in a header such as employees[6]{id,name,role}: and each object becomes one comma-separated row. The [6] declares how many rows follow, which helps a model, and a decoder, notice missing or truncated data.

The savings come from not repeating keys, quotes and braces for every item. The employee list loaded in the converter above is 360 tokens as pretty JSON, 209 as minified JSON and 144 as TOON, counted with o200k_base, the tokenizer used by GPT-5 and GPT-4o.

How to convert JSON to TOON

  1. 1

    Paste or open JSON

    Paste JSON into the left pane, press Open file to read a .json file from your device, or drop the file on the pane. The Sample menu loads five data shapes to try.

  2. 2

    Check the TOON output

    TOON appears on the right as you type. Invalid JSON shows the line, the column and a plain-English fix, and Go to line selects the problem line.

  3. 3

    Compare token counts

    The comparison under the editor counts TOON, minified JSON and pretty JSON with a real GPT tokenizer and tells you which one to send for this data.

  4. 4

    Copy, download or reverse

    Copy the TOON, use Copy for prompt to wrap it in a ```toon code block, download a .toon file, or press Swap to turn TOON back into JSON.

When does TOON save tokens, and when doesn't it?

TOON saves the most tokens on arrays of objects that share the same keys, and it can use more tokens than minified JSON on deeply nested or irregular data. The five samples in the converter show the range. Counts below use o200k_base with the default comma delimiter and 2-space indent.

Token counts for the converter samples as pretty JSON, minified JSON and TOON
Sample dataPretty JSONMinified JSONTOONTOON vs minified JSON
Uniform table: 6 employees36020914431% fewer tokens
4 orders with a nested customer object2501429533% fewer tokens
Keyed map: revenue for 4 regions1881158823% fewer tokens
Event log with different keys per event19412414819% more tokens
Nested app config26615418319% more tokens

Why data shape decides the result

A table row in TOON carries only values, so the cost of the keys is paid once per array instead of once per item. The more rows an array has and the more keys each row repeats, the bigger the saving. That is why the employee list drops from 209 to 144 tokens.

Objects that are nested several levels deep, or arrays whose items have different keys, cannot become tables. TOON then writes each key on its own indented line, which costs more than the braces and commas of minified JSON. The official TOON benchmarks report the same pattern: on flat tabular data TOON used 58.7% fewer tokens than JSON and 35.2% fewer than compact JSON, while on mixed data it used 32.7% fewer than JSON but 1.6% more than compact JSON.

The converter shows the shape of your data under the token bars, counting tables, rows and list arrays, so you can see why it won or lost. If minified JSON wins, it says so.

What this TOON converter does

Exact token counts
Counts use the o200k_base or cl100k_base tokenizer running in your browser, the same tokenizer family the official TOON benchmarks use, not a characters divided by four guess.
An honest verdict
TOON is compared with minified JSON as well as pretty JSON, and the tool tells you when minified JSON is the smaller choice.
Two-way conversion
Convert JSON to TOON or TOON to JSON. Swap feeds the output back in, so you can check a round trip by hand.
Round-trip check
Every TOON result is decoded again and compared with your JSON, and the status line confirms the data came back identical.
Strict TOON validation
Decoding checks declared lengths, row widths, indentation, escapes and duplicate keys, then reports the line with a plain-English fix.
Current spec 4.4
Built on version 4.4.0 of the official library, so it writes nested field groups and keyed tables and quotes strings that start with #.
Delimiters and indent
Choose comma, tab or pipe between values and 2 or 4 spaces of indentation. The delimiter is declared in each array header.
Files stay on your device
Open .json, .toon and .txt files or drop them on the editor. Nothing is uploaded, and the page keeps working offline once loaded.

TOON syntax cheat sheet

These are the forms an encoder following TOON spec 4.4 writes. Indentation is 2 spaces per level unless you choose otherwise.

TOON syntax forms with examples
FormTOON exampleWhat it means
Key and valuename: AdaOne object field per line. A nested object is indented under its key.
Primitive arraytags[3]: admin,ops,devThe length goes in brackets and the values follow on the same line.
Tabular arrayusers[2]{id,name}:Each following line is one object, such as 1,Ada and then 2,Lin.
Nested field grouporders[2]{id,customer{name,country}}:A uniform nested object folds into the header, and rows stay flat: 7,Ada,UK.
Keyed tableregions[2:]{q1,q2}:An object whose values are uniform objects. Each row starts with its key: eu: 10,12.
List arrayitems[2]:Items with different shapes, one per line, each starting with a hyphen and a space.
Other delimiterstags[3|]: a|b|cA tab or pipe delimiter is declared inside the brackets. Comma needs no marker.
Empty valuestags: []An empty array. An empty object is a key with nothing indented under it.
Quoted stringnote: "a,b"Quotes are needed only when a string is empty, has outer spaces, contains the delimiter, a colon, quote, backslash or bracket, starts with a hyphen or #, or looks like a number, true, false or null.
Comment# noteFull lines starting with # are comments that decoders drop. Encoders never write them.

TOON vs JSON, YAML and CSV

Each format has a job it does best. TOON is aimed at one: putting structured data into a prompt cheaply while keeping enough structure for the model to read it reliably.

Comparison of TOON with JSON, YAML and CSV for LLM prompts
FormatBest forTokens on uniform arraysWatch out for
Pretty JSONAPIs, storage, codeHighest: keys, quotes and braces repeat for every itemIndentation alone can add a third or more
Minified JSONNested or irregular data in promptsMediumHard for people to read and review
YAMLConfig filesMedium: keys still repeat for every itemIndentation mistakes change meaning
CSVFlat tables onlyLowest, about 5 to 10% under TOONNo nesting, no types and no declared row count
TOONUniform arrays and tables inside promptsLow: keys written once per arrayModels learn it from the prompt, and irregular data can cost more than minified JSON

How to use TOON in an LLM prompt

Put the TOON inside a fenced code block labelled toon and add one line that says what it is, for example: Data is in TOON format; [N] is the number of rows and {fields} lists the columns. Copy for prompt in the converter adds the fence for you. Models generally read TOON without a long explanation because it looks like a mix of YAML and CSV.

If you want a model to answer in TOON, show the exact header you expect, such as results[N]{id,score,reason}:, and decode the reply with TOON to JSON before your code uses it. Strict validation catches a reply that stops early, because the row count will not match the declared length.

Keep in mind that explaining a new format costs tokens too. A February 2026 benchmark by Ivan Matveev found that this prompt overhead can cancel the savings on short inputs, so TOON pays off most on larger payloads such as tables of search results, records or metrics.

Common uses for JSON to TOON conversion

RAG and search results
Retrieved records with the same fields, such as products, tickets or documents with metadata, turn into compact tables.
Database and analytics rows
SQL query results and metrics exported as JSON arrays are the best case for TOON, often 30% or more below minified JSON.
Agent tool results
Shrink the JSON an API or tool returns before it goes back into the model's context window.
Few-shot examples
Show many labelled examples in less space by listing them as rows under one header.
Budgeting a prompt
Check how many tokens a dataset will cost in each format before you choose one for production.
Reading model output
Decode TOON a model produced back into JSON and validate the row counts before you store it.

Convert JSON to TOON in code

The converter is quickest for one-off checks. For pipelines, the official packages do the same conversion.

Official TOON packages and example commands
WherePackageExample
TypeScript and JavaScript@toon-format/toonimport { encode, decode } from '@toon-format/toon'; const toon = encode(data)
Command line@toon-format/clinpx @toon-format/cli input.json -o output.toon
Command line, with stats@toon-format/clinpx @toon-format/cli data.json --stats
Pythontoon-formatpip install toon-format, then from toon_format import encode, decode

JSON to TOON questions

What is TOON format?

TOON (Token-Oriented Object Notation) is a compact, human-readable encoding of JSON data for LLM prompts. It uses indentation for nesting and writes arrays of similar objects as tables with one header, so keys are not repeated for every item.

How many tokens does TOON save compared with JSON?

It depends on the shape of your data. Uniform arrays of objects usually use 30 to 60% fewer tokens than pretty JSON and 20 to 35% fewer than minified JSON. Deeply nested or irregular data can use more tokens than minified JSON. The comparison in the converter measures your own data, so you do not have to guess.

Is TOON better than JSON for LLMs?

For input data built around large uniform arrays, usually yes: fewer tokens with similar accuracy. The official benchmark across 4 models reports 72.2% retrieval accuracy for TOON and 71.4% for JSON while TOON used 42.6% fewer tokens. For nested configs, small payloads, or output that other code must parse, JSON is often the safer choice.

Is the conversion from JSON to TOON lossless?

Yes for valid JSON. TOON encodes the same data model, and this converter decodes every result again and compares it with your input. Two limits come from JSON parsing in any browser: integers above 9,007,199,254,740,991 lose precision, and duplicate keys keep only the last value.

Which TOON spec version does this converter follow?

Spec 4.4 from October 2026, through version 4.4.0 of the official TypeScript library. It folds uniform nested objects into the table header, writes objects of uniform objects as keyed tables, and quotes strings that start with #. Converters built on 2.x libraries leave a value like #tag unquoted, and a 4.x decoder drops that line as a comment.

How accurate are the token counts?

They are exact for OpenAI models. The converter runs the o200k_base tokenizer (GPT-5, GPT-4.1, GPT-4o, o3) or cl100k_base (GPT-4, GPT-3.5) in your browser. Claude, Gemini and Llama use their own tokenizers, so their absolute numbers differ, but the ranking between TOON and JSON is usually the same.

Which delimiter should I choose?

Comma is the default and the easiest to read. Tab often saves a few more tokens because values rarely contain tabs, so fewer strings need quotes. Pipe is a readable middle ground. The choice is written into each header, for example [3|], so decoders know which one you used.

Why does my TOON fail to decode?

Strict validation checks that each declared length matches the rows or items that follow, that every row has as many values as the header has fields, that indentation is a multiple of the indent size, and that keys are not repeated. The error names the line, and Go to line selects it. Turning off Strict applies the spec's limited recoveries, such as ignoring a wrong length.

Can I open .toon files?

Yes. Press Open file and choose a .toon, .json or .txt file, or drop it on the input pane. The direction switches to match the file type. TOON files use the .toon extension and the provisional media type text/toon.

Is my data sent to a server?

No. Parsing, conversion and token counting all run in your browser with JavaScript. Your JSON is never uploaded, logged or stored, which makes the converter safe for customer records and internal data.

100% private: your data never leaves your browser

No registration, no tracking of your content, no server uploads. Don't just take our word for it:

  • No server, no uploads

    Your files and text are processed entirely on your device. Nothing is ever sent to us.

  • Works offline

    Once loaded, this tool keeps working with your Wi-Fi turned off. Try it.

  • Verify it yourself

    Open your browser's DevTools → Network tab. You'll see zero requests carrying your data.

Explore more tools

More utilities for your next task.

Browse all tools