JSON to TOON: A Compact Format for LLM Prompts – and When to Use It

If you send the same JSON shape to an LLM over and over — agent tool calls, RAG context chunks, batch evaluations, fine-tuning samples — every repeated "name": and "price": and "in_stock": costs you tokens. Over millions of calls, those tokens add up to real money. TOON (Token-Oriented Object Notation) is an experimental format designed to attack exactly that problem: write each object key once, then list the values in compact rows below it.

One thing up front: TOON is not an industry standard, has no RFC, and is not a replacement for JSON in production APIs. Treat it as one tool in your prompt-optimization toolkit, alongside minification, schema simplification, and prompt-side dedup. This guide explains what TOON is, exactly how the savings are measured, where they show up, and where they don't.

Try the converter in your browser — free, no signup:

Open JSON to TOON Converter →

What is TOON?

TOON stands for Token-Oriented Object Notation. It is a recent, community-driven serialization style that grew out of prompt-engineering practice. Its lineage is closest to YAML — indentation rather than braces, colons after keys — but it adds one distinctive idea: when an array contains many objects with the same shape, the keys are written once as a header and the values follow as compact comma-separated rows.

Here is the same data in JSON and in TOON, side by side:

// JSON
{
  "users": [
    {"id": 1, "name": "Alice", "age": 30},
    {"id": 2, "name": "Bob",   "age": 25}
  ],
  "settings": {"theme": "dark", "beta": true},
  "tags": ["alpha", "beta", "gamma"],
  "notes": ""
}
# TOON
users[2]{id,name,age}:
  1,Alice,30
  2,Bob,25
settings:
  theme: dark
  beta: true
tags: [alpha, beta, gamma]
notes: ""

The structural braces, the repeated quote characters around every key, and the repeated key names themselves are all gone from the users array. That is where most of the savings come from. Scalar arrays compact inline (tags: [alpha, beta, gamma]), nested objects use plain indentation, and empty strings stay explicit ("") so they can be distinguished from missing values.

Why TOON can save tokens (when it does)

To understand where savings come from, it helps to remember that LLM tokenizers do not count characters — they count tokens, which are sub-word units produced by a Byte-Pair Encoding (BPE) algorithm. A common English word like name is typically one token. The string "name": in JSON, however, is usually two or three tokens because the quote characters and the colon push it across BPE boundaries.

Multiply that across an array of 50 user objects with five fields each, and JSON's repeated key syntax has just spent roughly 50 × 5 × (2 to 3) = 500 to 750 tokens on key names alone — before any of your actual data. TOON collapses every one of those repetitions into one header row of about 10 tokens.

Important caveat: character count and token count are correlated but not identical. A 40 percent reduction in characters does not automatically mean a 40 percent reduction in tokens. TOON's comma-separated rows and bracket-and-brace tokens may tokenize differently on OpenAI's o200k_base, Anthropic's tokenizer, Gemini's tokenizer, and local model tokenizers. The two numbers tend to move in the same direction, but the ratio between them varies.

A measured comparison

Methodology: Character counts are measured directly from the JSON and TOON strings using string.length. JSON is compared in its minified form (the smallest fair baseline). Token estimates use OpenAI's o200k_base BPE tokenizer as a representative reference. Actual savings vary by tokenizer (OpenAI vs Anthropic vs Gemini vs local models), payload structure, and content. The first two rows below come from the Load Example payloads in the converter, so you can reproduce the numbers yourself.

Payload type JSON chars TOON chars Char saving ~ Token reduction (o200k_base)
3-product catalog (4 fields each) 214 126 ~41% ~25–30%
Service config (5 keys, 2 nested objects) 178 159 ~11% negligible
50 user records (uniform 5-field array) ~4,060 ~2,090 ~48% ~30–35%

The shape of the result is consistent: repetitive uniform arrays of objects benefit the most, nested non-repetitive configs benefit little. The 50-row case is the realistic "agent tool result" or "RAG context chunk" pattern, and it is where TOON earns its keep.

When TOON is the right choice — and when it isn't

Right choice:

Wrong choice:

How to use the converter

The JSON to TOON Converter is the fastest way to experiment. Paste a JSON payload into the left panel and click Convert to TOON. The result appears on the right, with a savings indicator showing exact character counts and an estimated token-reduction range. If you do not have a payload handy, click Load Example to cycle through a built-in product catalog (the tabular case) and a nested service config (the non-tabular case) so you can see the difference between the two.

Once you have a TOON string, dropping it into a prompt is straightforward. With the OpenAI Node SDK it looks like this:

import OpenAI from 'openai';
const client = new OpenAI();

const toonContext = await fetch('/api/users')
    .then(r => r.json())
    .then(jsonToToon); // your conversion helper

const res = await client.chat.completions.create({
    model: 'gpt-4o',
    messages: [
        { role: 'system', content: 'You are a data summarizer.' },
        { role: 'user', content: `Summarize this user list:\n${toonContext}` }
    ]
});

If you want to validate the underlying JSON before converting, paste it into the JSON Validator first — the converter will reject invalid JSON, but the validator gives more precise error positions. For very large payloads, the JSON Minifier is also worth a look as a complementary technique: minifying alone often gets you 10–20 percent without changing the format at all.

Frequently Asked Questions

What is TOON format?

TOON stands for Token-Oriented Object Notation. It is an emerging, experimental serialization style that grew out of the prompt-engineering community as a way to fit more structured data into LLM context windows. Its lineage is closest to YAML — it uses indentation rather than braces — but it adds one important idea: when an array contains many objects with the same shape, the keys are written once as a header and the values follow as compact rows. TOON is not an industry standard, has no governing body, and is not a replacement for JSON in machine-to-machine APIs. Treat it as one optional tool in your prompt-optimization toolkit.

How do I convert JSON to TOON with this tool?

Open the JSON to TOON Converter, paste your JSON into the left panel (or click Load Example to see a built-in payload), then click Convert to TOON. The TOON output appears on the right along with a savings indicator that shows how many characters were saved versus the minified JSON. Copy moves the result to your clipboard; Download saves it as a .toon file. Everything runs in your browser, so no JSON or TOON ever leaves your device.

Will TOON actually reduce my OpenAI or Anthropic token bill?

Sometimes yes, sometimes barely. Token savings depend on three things: how repetitive your payload is, what tokenizer the model uses, and how the structural characters of TOON (commas, brackets, colons) tokenize relative to JSON's. Highly repetitive arrays of uniform objects — agent tool call lists, RAG context chunks, batch evaluation inputs — typically see the largest reductions because the repeated key names collapse into a single header row. Small payloads, deeply nested non-uniform structures, and payloads with little repetition often see little or no benefit, and occasionally TOON is even slightly larger. The only way to know for your data is to measure with the tokenizer your model actually uses.

Does this tool send my JSON to a server?

No. The JSON to TOON converter is a client-side JavaScript tool — the conversion runs entirely in your browser, and your JSON is never transmitted to any server. Every other tool on JSON Dev Tools (the JSON Formatter, JSON Validator, JWT Decoder, and the various format converters) follows the same browser-only design, which is why none of them require an account or store any of your input data.

Can I convert TOON back to JSON?

Not in this tool today — the converter is one-way. TOON's spec is still evolving and there is not yet a single canonical parser the way there is for JSON. If round-tripping matters to you, the safer pattern is to keep the original JSON as your source of truth, generate TOON only at the moment you build the LLM prompt, and parse the model's response back as JSON. A few open-source TOON parsers are starting to appear if you do want to read TOON back, but their behaviour around quoting and tabular arrays varies — verify with your own samples before depending on one.

JSON to TOON Converter

Paste any JSON, click Convert, and see the TOON output with a real character-savings number. Browser-only, no signup, no data leaves your device.

Open JSON to TOON Converter
About the author

Pasindu Ishan is a software developer based in Sri Lanka. He builds developer tools at JSON Dev Tools.