The Problem with JSON in AI

JSON (JavaScript Object Notation) has long been the standard for representing structured data. Developers use it everywhere, from database storage to API payloads. It's easy to read and versatile. But in the new era of AI and LLMs (like OpenAI’s GPT or Claude), how we send data really matters—down to each character and space.

When you send a JSON-encoded prompt to an LLM, every character, including braces, quotes, and spaces, is counted as a separate token. LLMs charge you based on token usage—for both inputs and outputs—so unnecessary characters can quickly inflate your costs and slow things down. The more verbose your JSON, the more you pay and the longer your LLM responses take to generate.

Introducing TOON: Token-Oriented Object Notation

TOON is a compact, human-readable format created specifically for sending data to LLMs. Its purpose is to use significantly fewer tokens than JSON.

Unlike JSON, which uses braces, double quotes, colons, and commas to define structure, TOON borrows the indentation rules of YAML and the tabular simplicity of CSV for organizing information. This results in much leaner prompts—especially effective when your data contains lots of flat, repetitive objects.

Key Benefits of TOON

How Does It Work?

Let’s look at a common scenario:

In JSON, you might send this:

  
    {
  "users": [
    { "id": 1, "firstName": "Alice", "interests": ["music", "travel"] },
    { "id": 2, "firstName": "Bob", "interests": ["coding", "books"] }
  ]
}
  

In TOON, the data could look more like this (simplified):

  
    users 2
  id  firstName  interests
  1   Alice      music, travel
  2   Bob        coding, books
  

There are no extra braces, quotes, or commas—the structure is clear from the indentation and new lines. The format drops anything redundant, reducing the overall number of tokens processed by the LLM.

Real-World Benchmark

A key highlight from the video: When tested, TOON reduced token usage dramatically in flat data structures. For instance, where JSON required 10,000 tokens, TOON used only about 4,500. This directly translates to lower costs and faster inference. However, with highly nested data, TOON can sometimes use more tokens than flat JSON, so it works best when you can flatten your structure before encoding.

How to Use TOON

When TOON Works Best

Limitations and Learning

Conclusion

TOON is new but growing rapidly. If you’re building AI or LLM-based tools and want to improve performance, try using Token-Oriented Object Notation. Flatten your data, encode it with TOON, and see the token savings for yourself. As with any new tool, keep an eye out for community updates and share your experiences to help the format mature.