TOON Format Documentation

Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model for LLM prompts.

What is TOON?

TOON provides a lossless serialization of the same objects, arrays, and primitives as JSON, but in a syntax that minimizes tokens and makes structure easy for models to follow.

TOON combines YAML's indentation-based structure for nested objects with a CSV-style tabular layout for uniform arrays. Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input.

Key Features

💸 Token-Efficient

Typically 30-60% fewer tokens on large uniform arrays vs formatted JSON

🤿 LLM-Friendly Guardrails

Explicit lengths and fields enable validation and improve accuracy

🍱 Minimal Syntax

Removes redundant punctuation (braces, brackets, most quotes)

📐 Indentation-Based Structure

Like YAML, uses whitespace instead of braces for nested objects

Syntax Guide

Basic Array

JSON:

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

TOON:

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

Nested Objects

JSON:

{
  "user": {
    "name": "Alice",
    "role": "admin"
  }
}

TOON:

user:
  name: Alice
  role: admin

Mixed Data Types

JSON:

{
  "total": 3,
  "active": true,
  "items": ["a", "b", "c"]
}

TOON:

total: 3
active: true
items[3]: a,b,c

When to Use TOON

✅ Use TOON When:

  • Sending data in LLM prompts (ChatGPT, Claude, GPT-4, etc.)
  • Working with uniform arrays of objects (like database results)
  • Token costs are a concern
  • You need explicit validation (array lengths, field names)
  • Improving LLM accuracy on structured data

❌ Avoid TOON When:

  • Deeply nested or non-uniform structures (JSON may be more efficient)
  • Semi-uniform arrays (~40-60% tabular eligibility)
  • Pure tabular data (CSV is smaller for flat tables)
  • API responses that will be parsed by code
  • Standard web development (REST APIs, configs, etc.)

Performance Comparison

Efficiency Ranking (Accuracy per 1K Tokens)
Overall performance across 4 LLMs on 209 questions
TOON26.9 • 73.9% acc • 2,744 tokens
JSON compact22.9 • 70.7% acc • 3,081 tokens
YAML18.6 • 69.0% acc • 3,719 tokens
JSON15.3 • 69.7% acc • 4,545 tokens
XML13.0 • 67.1% acc • 5,167 tokens

Key result: TOON achieves 73.9% accuracy (vs JSON's 69.7%) while using 39.6% fewer tokens.

Frequently Asked Questions

Is TOON lossless?

Yes, TOON is 100% lossless. Converting JSON → TOON → JSON will always produce identical results.

Which LLMs support TOON?

All major LLMs can parse TOON (ChatGPT, Claude, GPT-4, Gemini, Grok). TOON is just structured text that LLMs can understand.

How much can I save?

Typically 30-60% fewer tokens on uniform arrays. Actual savings depend on your data structure. Use our comparison tool to test your specific data.

When should I use CSV instead of TOON?

Use CSV for pure flat tabular data where every token counts. TOON adds ~5-10% overhead but provides structure that improves LLM reliability.