Data

JSON to TOON Converter — Cut LLM Prompt Tokens

Convert JSON to compact TOON and back, with a token-count comparison for LLM prompts.

Runs entirely in your browser — nothing you paste is uploaded or stored.

TOON
TOON appears here.

What is json to toon converter?

TOON (Token-Oriented Object Notation) is a compact way to write JSON data that is meant for LLM prompts. JSON repeats every field name on every object, so a list of 100 users spells out "id", "name" and "role" 100 times, and every one of those repeats costs tokens. TOON writes a uniform array as a table, with the field names declared once in a header and one comma-separated row per item, and it uses indentation instead of braces for nested objects. The data model is identical to JSON, so the conversion is lossless in both directions. This tool converts either way with the official encoder, lets you choose the delimiter and indent, and shows an estimated token count for pretty JSON, minified JSON and TOON side by side, so you can see whether it is worth using for your data.

When to use it

  • Shrinking a large list of records before putting it in a prompt, a system message or a RAG context, where every token costs money and context window.
  • Checking how much TOON would actually save on your own data before changing a pipeline, since the saving depends heavily on its shape.
  • Reading a TOON block that a model or another tool produced by converting it back to JSON.
  • Producing a TOON fixture for tests, or for documentation that shows the format with real data.

How to use this tool

  1. Paste JSON, or click "Load example" to see a working sample.
  2. Read the TOON on the right, plus the token comparison underneath it.
  3. Choose a delimiter (comma, tab or pipe) and an indent width if you need a different style.
  4. Switch to TOON → JSON to go the other way. The current result moves across to become the new input.
  5. Copy the result, download it, or copy a link that restores this exact input and its options.

Example

A list of users and a tag list, converted to TOON.

Input

{
  "users": [
    { "id": 1, "name": "Alice", "role": "admin" },
    { "id": 2, "name": "Bob", "role": "user" },
    { "id": 3, "name": "Carol", "role": "user" }
  ],
  "tags": ["api", "beta"]
}

Output

users[3]{id,name,role}:
  1,Alice,admin
  2,Bob,user
  3,Carol,user
tags[2]: api,beta

The field names appear once in the header, and the [3] and [2] are the item counts, which let a reader or a parser notice a truncated list.

Why the format saves tokens

JSON is verbose for lists of records because the structure is repeated: every object re-states its keys, quotes and braces. TOON states the structure once. A table header such as users[3]{id,name,role}: declares the array length and its columns, and each row is then just the values. That is also why the saving grows with the number of rows and shrinks for data with varying fields, where TOON falls back to a longer list form.

The encoding comes from the official @toon-format/toon package, so the output follows the specification rather than an approximation of it.

Frequently asked questions

How much does TOON actually save?

It depends on the shape of the data. A long list of objects that all have the same fields is where TOON shines, because the field names are written once instead of once per row, and the saving grows with the number of rows. Deeply nested or irregular data saves little, and sometimes TOON is no smaller than minified JSON. This tool shows the comparison for your own data so you do not have to guess.

Are the token counts exact?

No. They are estimates using a tokenizer heuristic, and real counts differ by model. The comparison is reliable for judging relative size, but use the LLM Token Counter or your provider's counter if you need a number to budget against.

Is the conversion lossless?

Yes. TOON encodes the same data model as JSON (objects, arrays, strings, numbers, booleans and null), and strings that could be misread, such as "true", "42", an empty string or one containing the delimiter, are quoted automatically. Converting to TOON and back gives you the original data. Key order is preserved, but whitespace and number formatting in the original JSON text are not.

Can a model read TOON reliably?

It is plain text with an explicit header that names the columns and the row count, so it is easy for a model to follow. This site has not benchmarked accuracy, and results vary by model and task, so test with your own prompts before relying on it. When you need a model to produce structured output for a program, JSON is still the safer choice because tooling and structured-output features expect it.

Which delimiter should I pick?

Comma is the default and the most readable. Tab and pipe are useful when your values contain many commas, because values that contain the active delimiter have to be quoted, which costs tokens. The chosen delimiter is recorded in the array header, so the output can always be read back.

Why does TOON → JSON report an error on my text?

The decoder is strict. It rejects inconsistent indentation, a row count that does not match the header, and rows with the wrong number of fields. The error names the line, which is usually enough to spot the mismatch. A truncated or hand-edited block is the most common cause.

Is my data sent anywhere?

No. Conversion runs entirely in your browser tab and nothing you paste is uploaded. The encoder loads only when you first use this tool.

Is there a size limit?

Yes, 500,000 characters. Conversion is synchronous and runs in your browser tab, so a larger input could freeze the page.

Find these tools useful? A coffee helps keep them free and ad-light.

Buy me a coffee