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.
Keys written once, not per row
Biggest saving on uniform arrays of records
Round-trips to JSON and back
Same data, just a different layout
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],falseArray Name & Length
users = Array name
[3] = Number of records (3 users)
Field Names
Lists field names once in curly braces
Separated by commas, defines column order
Data Rows
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
❌ Wrong
2Field Names in Curly Braces
List all field names inside curly braces {field1,field2}, separated by commas.
✅ Correct
❌ Wrong
3Colon After Header
End the header line with a colon : before listing data rows.
✅ Correct
❌ Wrong
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
❌ Wrong (says [2] but has 3 rows)
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,trueExample 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,FurnitureExample 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%,1Example 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,BobBest for: Most use cases
Standard delimiter, works well with simple data
Tab Delimiter
users[2 ]{id name}:
1 Alice
2 BobBest for: Large uniform tables
Often tokenizes better, fewer escaping issues
Pipe Delimiter
users[2|]{id|name}:
1|Alice
2|BobBest 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.
JSON to TOON
Convert JSON to TOON format
TOON to JSON
Convert TOON back to JSON
TOON Validator
Validate TOON syntax
TOON Formatter
Format TOON for readability
TOON Minifier
Compress TOON data
TOON Viewer
Visualize TOON structure
CSV to TOON
Convert CSV to TOON
YAML to TOON
Convert YAML to TOON
TOON to Table
Display TOON as tables
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.
Learn More About TOON Format
Essential Reading
- What is TOON Format?
Complete introduction for beginners
- TOON Format Specification
Detailed technical specification
- TOON vs JSON Comparison
Side-by-side format comparison
- TOON Format Examples
Real-world use cases and examples
Implementation Guides
- Using TOON in Python
Python integration tutorial
- Using TOON in Java
Java implementation guide
- Using TOON in C#
C# integration tutorial
- TOON for LLM Prompts
Best practices for AI applications
Related Tools
TOON to Table
Convert TOON format to HTML tables for easy visualization
TOON Formatter
Format and beautify TOON data with custom delimiters and options
TOON Fixer
Fix broken TOON data automatically, repair malformed delimiters, column mismatches, and structural errors
JSON to TOON
Convert JSON to TOON format - 50% fewer tokens for LLM prompts
TOON to JSON
Convert TOON format back to JSON with validation
CSV to TOON
Convert CSV data to TOON format for optimized LLM prompts