JSON-TOON Converter

Convert JSON data to TOON — a compact, bracket-free encoding optimized for LLM prompts. 40% fewer tokens, fully reversible, runs in your browser.

JSON Input
TOON Output

What is TOON?

TOON (Token-Oriented Object Notation) is a compact, bracket-free encoding of JSON data designed for LLM prompts. It uses indentation instead of brackets, reducing token count by ~40% compared to standard JSON. TOON is fully reversible — convert back to JSON losslessly.

JSON

{
  "user": "Ning",
  "role": "engineer",
  "skills": ["Python", "Go"]
}

TOON

user: Ning
role: engineer
skills[2]: Python,Go

How to Convert JSON to TOON

1. Paste Your JSON

Paste or type valid JSON data into the input panel on the left.

2. Click Convert

Press the Convert button. The converter transforms your JSON to TOON instantly in the browser — no data leaves your machine.

3. Copy the TOON Output

Copy the TOON output and paste it into your LLM prompt. Expect ~40% fewer tokens compared to the raw JSON.

TOON Syntax Quick Reference

TOON uses five core patterns to represent any JSON structure. All patterns are indent-based with no brackets.

PatternTOONJSON
Objectkey: value{"key": "value"}
Nested Objectparent: child: value{"parent": {"child": "value"}}
Primitive Arraytags[3]: a,b,c{"tags": ["a","b","c"]}
Tabular Arrayusers[2]{id,name}: 1,Alice 2,Bob{"users": [{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}]}
Mixed Arrayitems[2]: - value - key: val{"items": ["value", {"key":"val"}]}

Token Savings: JSON vs TOON

Real-world token counts measured with the cl100k_base tokenizer (GPT-4 / Claude). TOON consistently reduces token usage, with the biggest gains on tabular data.

Data TypeJSON TokensTOON TokensSavings
Flat object (5 fields)2818-36%
Array of 10 objects (3 fields)14272-49%
Nested object (3 levels)6442-34%
Mixed array (5 items)4832-33%
Large tabular (100 rows, 5 cols)1,820920-49%

TOON vs JSON vs YAML vs CSV

Each format has trade-offs. TOON is designed specifically for LLM input — not as a general-purpose data format.

FeatureTOONJSONYAMLCSV
Token-efficientYesNoPartialYes
Human-readableYesPartialYesPartial
Lossless (JSON model)YesYesYesNo
Nested structuresYesYesYesNo
Tabular optimizationYesNoNoYes
Length validation [N]YesNoNoNo
LLM-optimizedYesNoNoNo

When to Use TOON

Best for

  • Feeding structured data to LLMs
  • Uniform arrays of objects
  • Reducing token costs
  • Adding structural validation

Not ideal for

  • Deeply nested structures
  • Mixed non-uniform arrays
  • Latency-critical paths

Frequently Asked Questions

What is TOON?

TOON (Token-Oriented Object Notation) is a compact, bracket-free encoding of JSON data. It uses indentation instead of brackets and commas, reducing token count by approximately 40% compared to standard JSON. TOON is fully reversible — you can convert back to JSON losslessly.

Why use TOON for LLM prompts?

LLMs process tokens, not characters. TOON is designed to express the same data with fewer tokens, reducing cost and context usage. The official TOON format claims ~40% token reduction on mixed structures, making it ideal for feeding large datasets into prompts.

Is TOON a replacement for JSON?

No. TOON is not meant to replace JSON for APIs, configuration, or general data exchange. It's specifically optimized for LLM input scenarios. For any context where JSON is the standard (APIs, databases, config files), keep using JSON.

Does it work offline?

Yes. All conversion happens entirely in your browser using JavaScript. No data is sent to any server.

Is the conversion lossless?

Yes. TOON is a lossless encoding of the JSON data model. Converting JSON → TOON → JSON produces identical output, and vice versa.

What tokenizer savings does TOON achieve?

On real-world datasets, TOON reduces token count by 30–50% compared to standard JSON when measured with cl100k_base (GPT-4 / Claude tokenizer). The savings are highest on uniform object arrays (tabular format), where repeated keys are eliminated entirely.

Can LLMs output TOON directly?

Yes. You can instruct LLMs to generate TOON output. However, for production use, always validate the output with a strict TOON decoder to catch truncation, missing fields, or malformed syntax. The TOON spec includes a strict mode specifically for this purpose.

How does TOON handle special characters and Unicode?

TOON uses UTF-8 encoding and supports all Unicode characters. Strings only need quoting when they could be misinterpreted as numbers, booleans, or null, or when they contain commas in array contexts. CJK characters, emoji, and other Unicode work without quoting.