Introducing TOON: A Token-Efficient Format for LLM Prompts

📝 Format Design 5 min read

We're excited to introduce TOON (Token-Oriented Object Notation), a compact serialization format designed specifically for sending structured JSON data to large language models. Unlike minified JSON, which saves bytes but is unreadable, or pretty-printed JSON, which is readable but token-heavy, TOON aims to give you both: fewer tokens and a format humans can still scan and edit.

🤖 The Problem with Sending JSON to LLMs

When you build AI agents, RAG pipelines, or chatbot tools, you often need to stuff lists of records — search results, database rows, API responses — directly into a prompt. JSON is the natural choice, but it repeats every field name for every object in an array, which burns tokens fast. Every token in the prompt costs money and counts against the model's context window.

Example: A List of Records in JSON

{
  "users": [
    { "id": 1, "name": "Alice", "role": "admin" },
    { "id": 2, "name": "Bob", "role": "editor" },
    { "id": 3, "name": "Carol", "role": "viewer" }
  ]
}

Notice that "id", "name", and "role" are each repeated once per object. In JSON, that per-object key repetition is the main source of wasted tokens. For a large list of search results or database rows passed as LLM context, this overhead adds up quickly.

Introducing TOON Format

TOON addresses this by declaring the field names for an array of uniform objects once, in a header line, and then listing each row as comma-separated values with no repeated keys. Here's the same user list in TOON:

Example: The Same List in TOON

users[3]{id,name,role}:
  1,Alice,admin
  2,Bob,editor
  3,Carol,viewer

The [3] declares the row count and {id,name,role} declares the field names once — every row afterward is pure data. TOON also supports plain nested objects with indentation instead of braces, and inline arrays of primitives with a count marker:

Example: Nested Objects and Primitive Arrays

location:
  city: Berlin
  country: DE
tags[3]: red,green,blue

🎯 Key Features of TOON

🪙 Fewer Tokens

By declaring field names once per array instead of repeating them per object, TOON's published benchmarks report roughly 42.6% fewer tokens than equivalent JSON on their test datasets.

👁️ Still Human-Readable

Unlike minified JSON, TOON stays easy to scan and edit by hand — indentation-based nesting and comma-separated rows keep the structure clear at a glance.

🎯 Comparable Retrieval Accuracy

In TOON's published benchmarks, LLMs retrieved information from TOON-formatted context with accuracy comparable to or better than JSON (72.2% vs. 71.4% in their tests), despite the smaller token footprint.

🔄 Full Compatibility

TOON maintains full data fidelity with JSON, so you can convert back and forth between the two formats without losing information.

🚀 Use Cases

TOON is particularly well-suited for:

🔮 The Roadmap for TOON Tooling

TOON is an evolving, open format, and there's more tooling we'd like to see grow around it. Some general directions for this site and the broader ecosystem:

🧰

Wider Language Library Support

More encoder/decoder libraries across languages and runtimes commonly used to build LLM applications

🧩

Editor Integrations

Syntax highlighting and validation for TOON in popular code editors

🔄

Conversion Tools

Continued improvements to converters between JSON and TOON, like the one on this site

💡 Getting Started

Ready to try TOON? Here's how to get started:

  1. Convert your existing JSON payloads using our online converter
  2. Explore the complete documentation to learn the syntax
  3. Check out the spec and reference implementation on GitHub
  4. Start by converting the arrays of records you already send to an LLM, since those benefit the most from TOON's tabular format

🌟 Pro Tip

TOON's biggest token savings come from arrays of uniform objects — records that all share the same fields, like search results or database rows. Prioritize converting those parts of your prompts first, since deeply irregular or single-object data will see smaller gains.

🤝 Join the Community

TOON is an open format, and we welcome contributions from developers building AI and LLM applications. Whether you're building a RAG pipeline, an agent framework, or a chatbot, your feedback and contributions help make TOON better for everyone.

🔄

Json Into Toon Team

Creators of the Toon format and converter tools