Table of Contents
- Introduction
- What is TOON (LLM Data Format)?
- The Problem with JSON Data Format in LLMs
- How TOON Solves This
- TOON vs JSON Comparison
- When Should You Use TOON?
- When JSON is Still Better
- Limitations of TOON
- Is TOON the Future?
- Conclusion
Introduction
Large language models (LLMs) can understand and work with different types of data, but sending large amounts of information to them can increase token usage and costs. The way data is structured can make a difference, especially when the same information is repeated many times.
JSON is one of the most widely used formats for sharing and storing structured data. However, it often repeats field names and uses extra characters, which can increase the number of tokens when sending data to large language models.
TOON (Token-Oriented Object Notation) is a newer data format designed to represent structured information in a more compact way. It aims to reduce repeated information and make data easier to send to LLMs.
In this blog, we will explore what TOON is, how it works, how it compares with JSON, and when each format makes sense for AI applications.
1. What is TOON (LLM Data Format)?
TOON (Token-Oriented Object Notation) is an experimental data format designed to represent structured data using fewer repeated keys and a more compact layout. It is especially useful to explore when working with large language models.
Unlike JSON, which repeats field names for each object, TOON can define the structure once and then list the values in a table-like format.
Key Ideas:
- Define the data structure once instead of repeating field names.
- Reduce unnecessary characters and repeated information.
- Represent similar records in a compact, table-like format.
- Make structured data easier to pass to large language models.
2. The Problem with JSON Data Format in LLMs
JSON is a popular format because it is easy to read, widely supported, and works well with different programming languages. However, when large amounts of repeated data are sent to an LLM, its structure can create extra token usage.
For example, consider the following JSON data:
[
{ "id": 1, "name": "Alice" },
{ "id": 2, "name": "Bob" }
]
Each record repeats the same field names, such as "id" and "name". This is useful for standard data exchange, but it can add extra tokens when a prompt contains hundreds or thousands of similar records.
Common Challenges:
- Field names are repeated in every object.
- Extra brackets, quotes, and commas add to the data size.
- Large datasets can use more tokens than expected.
- Higher token usage may increase the cost of working with LLMs.
This does not mean JSON is a bad format. It simply means that other formats may be worth considering when sending repeated structured data to large language models.
3. How TOON Solves This
TOON takes a different approach by defining the structure once and listing the related values below it. This can reduce repeated field names, especially when working with records that share the same structure.
TOON Example:
users[2]{id,name}:
1,Alice
2,Bob
In this example, the field names are defined in the first line. The following lines contain only the values for each user.
Benefits:
- Defines shared field names only once.
- Uses a compact format for repeated records.
- Can reduce token usage for suitable datasets.
- May help lower input costs when working with large language models.
The actual token savings depend on the data, tokenizer, and model being used. It is a good idea to test both formats with your own data before choosing one.
4. TOON vs JSON Comparison
When comparing TOON vs JSON, both formats have different strengths. JSON is a well-established standard for storing and sharing structured data, while TOON focuses on compact data representation for LLM-based workflows.
| Feature | TOON | JSON |
|---|---|---|
| Token Efficiency | Can be more efficient for repeated data | May use more tokens for repeated keys |
| Readability | Compact, table-like structure | Easy to read and widely understood |
| Repeated Field Names | Can define fields once | Usually repeats keys in each object |
| Tooling Support | Limited compared with JSON | Supported by many tools and libraries |
| LLM Use Cases | Designed for compact LLM data input | Can also be used with LLMs |
| Production Readiness | Still experimental and less widely adopted | Well-established and production-ready |
There is no single winner for every situation. The right choice depends on how your application handles data, what tools it uses, and whether reducing token usage is an important goal.
5. When Should You Use TOON?
TOON may be a useful option when you need to send large amounts of repeated, structured information to large language models.
Consider using TOON when:
- You are sending large tables or lists of similar records to an LLM.
- Reducing token usage and input costs is important.
- Your data contains repeated field names and a consistent structure.
- You are building AI applications that process structured information.
- You want to test more compact ways of providing context to an LLM.
For example, an AI application that sends hundreds of product records to a language model may benefit from testing TOON instead of sending the same information as repeated JSON objects.
6. When JSON is Still Better
Even with the benefits of TOON, JSON remains a strong choice for many software development projects. It is widely supported and works with almost every modern programming language and web technology.
Continue using JSON when:
- Building APIs and exchanging data between applications.
- You need reliable validation with tools such as JSON Schema or Pydantic.
- Storing and sharing structured data across different systems.
- Your application depends on existing JSON libraries and tools.
- Data compatibility and long-term maintenance are important.
For example, a backend built with FastAPI can use JSON to exchange data with a frontend, connect with external services, and handle API requests. There is no need to replace JSON just because a new format is available.
7. Limitations of TOON
TOON offers an interesting approach to working with large language models, but it also has some limitations that developers should understand before using it in a real project.
- Limited Adoption: TOON is still experimental and is not as widely used as JSON.
- Tool Support: There are fewer libraries and tools available compared with established JSON solutions.
- Model Compatibility: Different LLMs may handle unfamiliar data formats differently, so testing is important.
- Complex Data: Deeply nested or irregular data structures may be harder to represent clearly.
- Token Savings Vary: A compact format does not guarantee fewer tokens for every dataset or tokenizer.
Before using TOON in a production application, test its compatibility, parsing process, and actual token usage with the models and data you plan to use.
8. Is TOON the Future?
As more businesses start using large language models, the way data is prepared and shared with AI systems is becoming increasingly important. Developers are looking for ways to reduce token usage, manage costs, and send useful information without unnecessary repetition.
TOON introduces an interesting idea:
“Data formats for AI can focus on token efficiency as well as data structure.”
Although TOON is not ready to replace JSON, it highlights some useful possibilities for future AI development, such as:
- More compact ways to share structured data with LLMs.
- Better control over token usage in AI applications.
- Lower input costs for suitable data-heavy workflows.
- New approaches to preparing information for AI systems.
Its future will depend on developer adoption, available tools, model compatibility, and whether it provides clear benefits in real-world projects.
Conclusion
TOON and JSON both have a place in modern software development. TOON offers a compact way to represent repeated structured data and may help reduce token usage when working with large language models. JSON remains a reliable choice for APIs, databases, and general data exchange.
If you are developing AI applications, you can test TOON with suitable datasets and compare its token usage with JSON. Choose the format that best fits your application's requirements instead of replacing an established solution without a clear reason.
Use TOON when compact data representation and token efficiency are important.
Use JSON when compatibility, validation, and reliable data exchange are your priorities.
Frequently Asked Questions (FAQs)
TOON (Token-Oriented Object Notation) is an experimental data format designed to minimize token usage when working with LLMs. It defines the structure once and represents data in a compact, table-like format to avoid repeating keys and reduce costs.