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%.
Fewer Tokens
Compared to equivalent JSON
Reversible
Convert back to JSON anytime
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],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 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,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. 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:
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 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
- 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
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
TOON to Table
Convert TOON format to HTML tables for easy visualization
TOON Formatter
Format and beautify TOON data with custom delimiters and options
CSV to TOON
Convert CSV data to TOON format for optimized LLM prompts
TOON to CSV
Convert TOON format to CSV for spreadsheets and data analysis