TOON Format: Complete Guide

Everything you need to know about Token-Oriented Object Notation format

What is TOON Format?

TOON (Token-Oriented Object Notation) is a lightweight data format designed specifically for AI and LLM applications. Think of it as a more efficient alternative to JSON when working with language models like GPT-4, Claude, or Gemini.

Why TOON Format Exists

When you send data to an AI model, you're charged based on tokens (roughly words or word pieces). Traditional formats like JSON repeat field names for every record, wasting tokens and money.

TOON format solves this by listing field names once in a header, then providing just the values. This simple change cuts token usage by about 50%.

50%

Fewer Tokens

Compared to equivalent JSON

100%

Reversible

Convert back to JSON anytime

Easy

Human Readable

No special tools needed

TOON Format Structure Explained

TOON format has three main components. Let's break them down with a simple example:

users[3]{id,name,email,active}:
  1,Alice Smith,[email protected],true
  2,Bob Jones,[email protected],true
  3,Carol White,[email protected],false
1

Array Name & Length

users[3]

users = Array name

[3] = Number of records (3 users)

2

Field Names

{id,name,email,active}

Lists field names once in curly braces

Separated by commas, defines column order

3

Data Rows

1,Alice,alice@...,true

Just the values, comma-separated

One row per record, matches field order

TOON Format Syntax Rules

1Length Markers Are Required

Always specify the number of items in square brackets [N] after the array name.

✅ Correct

products[5]{...}

❌ Wrong

products{...}

2Field Names in Curly Braces

List all field names inside curly braces {field1,field2}, separated by commas.

✅ Correct

items[2]{id,name,price}

❌ Wrong

items[2] id,name,price

3Colon After Header

End the header line with a colon : before listing data rows.

✅ Correct

data[1]{id,value}: 1,hello

❌ Wrong

data[1]{id,value} 1,hello

4Match Row Count to Length

The number of data rows must match the length marker. If you say [3], you must have exactly 3 rows.

✅ Correct

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

❌ Wrong (says [2] but has 3 rows)

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

5Quote Strings with Commas or Special Characters

If a value contains commas, newlines, or quotes, wrap it in double quotes and escape internal quotes.

products[2]{id,name,description}:
  1,Widget,"A small, useful gadget"
  2,Gizmo,"Features: fast, durable, efficient"

Real-World TOON Format Examples

Example 1: Customer Database

A typical customer list with IDs, names, emails, and subscription status:

customers[4]{id,name,email,plan,active}:
  101,Sarah Mitchell,[email protected],Enterprise,true
  102,Michael Chen,[email protected],Pro,true
  103,Jennifer Kumar,[email protected],Basic,false
  104,Robert Taylor,[email protected],Pro,true

Example 2: Product Catalog

E-commerce products with prices and inventory:

products[3]{sku,name,price,stock,category}:
  WDG-001,Wireless Mouse,29.99,156,Electronics
  KBD-002,Mechanical Keyboard,89.99,43,Electronics
  DSK-003,Standing Desk,399.99,12,Furniture

Example 3: Log Entries for AI Analysis

Server logs that you want an AI to analyze:

logs[5]{timestamp,level,service,message,duration_ms}:
  2025-01-15T10:23:45Z,INFO,api,Request processed successfully,142
  2025-01-15T10:24:12Z,WARN,database,Connection pool near capacity,5
  2025-01-15T10:24:50Z,ERROR,auth,Invalid token signature,2
  2025-01-15T10:25:33Z,INFO,api,Request processed successfully,98
  2025-01-15T10:26:01Z,INFO,cache,Cache hit ratio: 94.5%,1

Example 4: Nested Objects

TOON format also supports nested structures using indentation (like YAML):

user:
  id: 1001
  name: "Alice Johnson"
  email: "[email protected]"
  address:
    street: "123 Main St"
    city: "Boston"
    zip: "02101"
  preferences:
    newsletter: true
    theme: "dark"

TOON Format Delimiter Options

TOON format supports three delimiter types. Choose based on your data and use case:

Comma (Default)

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

Best for: Most use cases

Standard delimiter, works well with simple data

Tab Delimiter

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

Best for: Large uniform tables

Often tokenizes better, fewer escaping issues

Pipe Delimiter

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

Best for: Data with many commas

Middle ground, good when commas appear in values

Choosing the Right Delimiter

  • Comma: Start here. Works for 90% of cases.
  • Tab: Switch if you have large datasets with consistent structure and want maximum efficiency.
  • Pipe: Use when your data has lots of commas (addresses, descriptions, etc.).

Work with TOON Format

Free tools to convert, validate, and work with TOON format:

Frequently Asked Questions

What does TOON format stand for?

TOON stands for Token-Oriented Object Notation. It's a data format designed specifically for token-based systems like LLMs (Large Language Models) such as GPT-4, Claude, and Gemini.

Is TOON format compatible with JSON?

Yes! TOON is fully reversible with JSON. You can convert JSON→TOON→JSON with zero data loss. TOON represents the same information as JSON, just more efficiently.

Where can I learn the complete TOON format specification?

Visit the official TOON GitHub repository for the complete specification, or read our detailed TOON format specification guide.

Can I use TOON format in my production applications?

Absolutely! TOON format is production-ready and used by many applications to reduce LLM API costs. It's well-tested, has clear specifications, and libraries available in multiple programming languages.

How do I validate my TOON format data?

Use our free TOON Validator tool. It checks for syntax errors, length mismatches, and structural issues. You'll get clear error messages if something's wrong.

What programming languages support TOON format?

TOON has official libraries for Python, JavaScript/TypeScript, Java, and more. Check the TOON GitHub for language-specific implementations. Also see our guides for Python, Java, and C#.

Learn More About TOON Format

Essential Reading

Implementation Guides