TOON Converter

Convert between JSON, CSV, XML, YAML and TOON format

~0 tokens
~0 tokens

What is TOON?

TOON (Token-Oriented Object Notation) is a revolutionary data serialization format specifically designed for the AI era. It's a compact, human-readable format that dramatically reduces token consumption when passing structured data to Large Language Models (LLMs) like GPT-4, Claude, or other AI systems.

Unlike traditional formats like JSON, XML, or YAML that were designed for general-purpose data exchange, TOON is optimized for token efficiency – a critical factor when working with LLMs that charge per token or have strict token limits.

Why TOON Matters

When working with LLMs, every token counts. Traditional JSON can be extremely verbose, especially with arrays of objects where field names are repeated for every item. TOON solves this by using a tabular format similar to CSV for uniform data, while maintaining the flexibility of nested structures like YAML.

Example Comparison:

JSON (verbose):

[{"id":1,"name":"Alice","role":"admin"},{"id":2,"name":"Bob","role":"user"}]

TOON (compact):

[2]{id,name,role}:
  1,Alice,admin
  2,Bob,user

Result: Up to 50% fewer tokens for the same data!

Key Features of TOON Format

🎯 Token Efficiency

Reduces token usage by up to 50% compared to JSON, saving costs and fitting more data within LLM context windows.

📊 Tabular Optimization

Excels at representing arrays of uniform objects (like database records) using a CSV-like format with headers.

📝 Self-Documenting

Explicit length markers [N] and field headers {field1,field2} make the structure immediately clear.

🌳 Nested Structures

Supports nested objects and arrays with YAML-like indentation, maintaining readability for complex data.

👁️ Human-Readable

Despite being compact, TOON remains easy to read and understand, making debugging and manual editing straightforward.

🤖 LLM-Friendly

LLMs can naturally parse and generate TOON format without special instructions, treating it like familiar YAML or CSV.

When to Use TOON Format

Perfect For:

  • LLM Prompts: Passing structured data to AI models while minimizing token usage and staying within context limits.
  • API Responses: Returning tabular data from APIs that will be consumed by LLMs, reducing processing costs.
  • AI Configuration Files: Storing settings and parameters for AI systems in a token-efficient format.
  • Data Serialization: Any scenario where you need to serialize structured data and token efficiency matters.
  • Database Exports: Converting database query results into a format optimized for AI processing.
  • RAG Systems: Storing and retrieving structured data in Retrieval-Augmented Generation pipelines.

Consider Alternatives When:

  • Non-LLM Applications: If you're not working with LLMs, standard JSON or XML might be more appropriate.
  • Highly Irregular Data: Data with inconsistent structures may not benefit as much from TOON's tabular optimization.
  • Existing Tooling: When you need extensive ecosystem support and libraries available for JSON/XML.

How TOON Format Works

TOON uses a combination of techniques to achieve maximum token efficiency while maintaining readability:

1. Tabular Arrays

For arrays of uniform objects (the most common case in structured data), TOON uses a header row with field names and data rows without repeating keys:

users[3]{id,name,role}:
  1,Alice,admin
  2,Bob,user
  3,Charlie,moderator

2. YAML-Like Indentation

Nested objects use 2-space indentation, similar to YAML, eliminating the need for braces and brackets:

user:
  id: 1
  profile:
    name: Alice
    email: [email protected]

3. Explicit Length Markers

Arrays include their length [N], helping LLMs track structure and validate data:

tags[3]: javascript,typescript,nodejs

4. Smart Quoting

Values are only quoted when necessary (e.g., containing commas or special characters), reducing unnecessary tokens:

simple: value
complex: "value, with comma"
number: 42
boolean: true

Getting Started with TOON

This TOON Converter makes it easy to start using TOON format in your projects:

  1. Convert Your Data: Paste your JSON, CSV, XML, or YAML data into the converter above.
  2. See the Savings: Watch the token count drop as your data is converted to TOON format.
  3. Use in LLM Prompts: Copy the TOON output and include it in your AI prompts or API calls.
  4. Convert Back: When needed, convert TOON back to JSON or other formats for processing.

💡 Pro Tip

TOON works best with tabular data (arrays of objects with consistent fields). The more uniform your data structure, the greater the token savings you'll achieve!

Learn More

For detailed syntax documentation, examples, and best practices for using TOON with LLMs, visit the official TOON format repository at github.com/toon-format/toon

Frequently Asked Questions

What is TOON format?

TOON (Token-Oriented Object Notation) is a compact, human-readable data serialization format designed for passing structured data to Large Language Models with significantly reduced token usage. It can reduce token consumption by up to 50% compared to JSON, making it ideal for AI applications where token efficiency matters.

How does TOON reduce token usage?

TOON reduces tokens by using a tabular format for arrays of objects (similar to CSV) where field names are declared once in a header instead of repeating for each item. It also uses YAML-like indentation for nested structures and smart quoting to minimize unnecessary characters. This approach eliminates redundant syntax while maintaining readability.

When should I use TOON format?

TOON is perfect for sending structured data to LLM prompts (GPT-4, Claude, etc.), API responses consumed by AI systems, configuration files for AI applications, and any scenario where token efficiency matters. It works best with tabular data – arrays of uniform objects with consistent fields, such as database query results or API responses.

Can I convert TOON back to JSON?

Yes! The TOON Converter supports bidirectional conversion. You can easily convert TOON to JSON, CSV, XML, or YAML formats. Simply select TOON as your input format and choose your desired output format. The converter preserves your data structure during conversion.

Is TOON format compatible with all LLMs?

Yes, TOON works with all major LLMs including GPT-4, Claude, Gemini, and others. LLMs can naturally parse and generate TOON format without special instructions because it resembles familiar formats like YAML and CSV. The self-documenting structure with explicit length markers helps models understand the data organization.

How accurate is the token estimation?

The token estimation uses a GPT-style tokenizer approximation that provides reasonably accurate estimates for most use cases. Actual token counts may vary slightly depending on the specific LLM tokenizer used (GPT-4, Claude, etc.), but the estimates are reliable for comparing token efficiency between formats.

Is this tool free to use?

Yes, the TOON Converter is completely free to use with no registration required. All conversions happen in your browser, so your data never leaves your device. There are no usage limits or restrictions.