</>CodeScrub

JSON ↔ TOON Converter

See exactly how many LLM tokens you save.

Paste data to see token comparison

DelimiterIndentKey folding
JSON Input
TOON Output
Output will appear here.
Ctrl + Enter convertCtrl + Shift + C copyCtrl + D download
Ad space · json-toon-mid

What Is TOON Format?

TOON (Token-Oriented Object Notation) is a data serialization format designed to reduce token consumption when sending structured data to large language models. It achieves 30–60% fewer tokens than JSON by declaring array field names once in a header and using indentation instead of braces. Created for the AI era, TOON is a lossless representation of JSON — anything encoded in TOON can be decoded back to identical JSON.

JSON vs TOON: Side-by-Side Comparison

JSON (37 tokens):

{"users":[{"id":1,"name":"Alice","role":"admin"},{"id":2,"name":"Bob","role":"user"}]}

TOON (15 tokens):

users[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user

What changed: keys are declared once in the tabular header, braces and quotes are dropped, and field names aren't repeated for every row. The schema ({id,name,role}) and explicit count ([2]) both help LLMs reason about the data more reliably than raw JSON.

When to Use TOON

Good fits:

  • Sending structured data in LLM prompts (GPT-4, Claude, Gemini API calls)
  • Fine-tuning datasets where token limits matter
  • AI agent frameworks (inter-agent communication, tool outputs)
  • Any token-sensitive workload where API costs scale with input size

Skip TOON for:

  • Traditional web APIs — JSON is universally supported
  • Deeply nested, non-uniform data — TOON savings diminish
  • Client-server communication that never touches an LLM

How Much Do You Save?

Data shapeTypical savings
Uniform array of objects (5+ items)40–60%
Mixed object with some arrays25–40%
Simple flat object15–25%
Deeply nested, non-uniform0–10% (JSON may win)

TOON Format Syntax

  • Objects use YAML-like indentation, no braces.
  • Uniform arrays use tabular headers: fieldName[count]{key1,key2,...}:
  • Rows are comma-separated values matching the header order.
  • Strings are quoted only when they contain the delimiter or special characters; everything else is unquoted.
  • Numbers, booleans, and null are unquoted and round-trip with their original types.

Privacy & Security

Your data never leaves your browser. All conversion and token counting happens client-side — no data is sent to any server, API, or LLM.