TOON Introduction

What is TOON?

Discover TOON (Token-Oriented Object Notation), the data format specifically engineered for the LLM era. Optimize your AI interactions with token-efficient serialization.

What is TOON?

TOON (Token-Oriented Object Notation) is a compact, text-based data serialization format specifically engineered for Large Language Models (LLMs). Unlike traditional formats like JSON or XML, which were designed for machine-to-machine communication, TOON is optimized to minimize "Token" consumption. It strips away redundant syntax (like repeated keys and excessive punctuation) to make data more "digestible" for AI models.

What is it used for?

The primary purpose of TOON is to optimize the interaction between humans (or systems) and LLMs. Its main use cases include:

Cost Reduction

By reducing the number of tokens required to represent data, it directly lowers the cost of using LLM APIs (like GPT-4 or Claude).

Context Window Expansion

It allows you to fit significantly more information (up to 2-3x more data) into the same limited context window.

Better Reasoning

The structured, table-like layout helps models better understand relationships between data points, improving accuracy in data extraction and analysis tasks.

Core Features

TOON provides unique capabilities tailored for AI model performance.

Token Efficiency

Eliminates repetitive keys in arrays and unnecessary quotes/braces.

LLM-Friendly Structure

Uses indentation and headers that align with how LLMs "attend" to text.

Schema-Aware Arrays

Defines the structure (keys) once at the top of a list rather than repeating them for every object.

Strict Counts

Includes explicit array lengths (e.g., items[5]), which helps the model verify data integrity and prevents "hallucinations" of extra items.

Syntax Rules

TOON blends the simplicity of YAML with the structure of a CSV file.

1

Objects

Use indentation and a colon (similar to YAML).

2

Arrays

Defined with a length and a header in curly braces.

3

Values

Quotes are optional for simple strings. No commas are needed at the end of lines.

example.toon
user:
  id: 101
  name: Alice
  tags: [3]{id, label}:
    1, developer
    2, tech-lead
    3, remote

TOON vs JSON

Comparing TOON with the industry standard JSON format.

FeatureJSONTOON
Token UsageHigh (High overhead due to brackets/quotes)Low (Optimized for density)
RedundancyKeys are repeated for every object in a listKeys are declared once per list
ReadabilityStandard for developersHighly readable for LLMs and humans
Data IntegrityImplicitExplicit (uses counts like [n])
Primary GoalGeneral data exchangeLLM efficiency

Usage Recommendations

When to choose TOON over other formats.

When to use

  • When sending large datasets (lists of products, users, or logs) to an LLM
  • When you are hitting the context limit of a model
  • When building AI Agents that need to process structured data frequently

When to avoid

  • For standard web development (browser-to-server communication), where JSON remains the industry standard
  • For extremely simple, non-nested data where the token savings are negligible