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, Gemini, and Meta AI.

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 solves this by listing field names once in a header, then providing just the values on each row. How much you save depends on the shape of your data: a long, uniform array of records saves the most, while a deeply nested or one-off object may save little or nothing.

Fewer tokens

Keys written once, not per row

Biggest saving on uniform arrays of records

Reversible

Round-trips to JSON and back

Same data, just a different layout

Plain text

Readable by eye

Write and edit it in any text editor

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 also handles nested structures with indentation, similar to YAML. Values are written bare; a string only needs quotes when it would otherwise read as a number, boolean, or null — here 02101 stays quoted so its leading zero is kept.

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 supports three delimiters. Comma is the default, so a comma header carries no extra marker. For tab or pipe, the delimiter character is declared inside the length marker as well — [N|] for pipe or [N ] for tab — and the same character separates the field names and the values.

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. It fits most data.
  • •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

Hands-on tools for converting to and from TOON, checking its syntax, and reshaping it. Everything runs in your browser — nothing you paste is uploaded or kept.

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 our detailed TOON format specification guide for complete documentation on syntax, rules, and advanced features.

Can I use TOON format in my production applications?

Yes. TOON has a published specification and open-source libraries, so you can read and write it in real projects. Whether it actually saves you tokens depends on your data — it helps most with uniform arrays of records and little with deeply nested or one-off objects, so measure it against your own prompts.

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. Also see our guides for Python, Java, and C#.

Learn More About TOON Format

Essential Reading

Implementation Guides