Posted in

What is TOON? A Simple Guide to Making AI Cheaper and Faster

What is TOON
What is TOON? A Simple Guide to Making AI Cheaper and Faster

If you’ve been working with AI, custom chatbots, AI agents, or automated data processors, and large language models (LLMs) lately, you’ve probably noticed something frustrating: everything costs tokens, or in other words, the currency of this new era. Every single character, bracket, and comma adds up. And if you’re using JSON to send data to AI models, you’re probably spending way more than you need to.

That’s where TOON comes in. It’s a new way to format data that could save you 30–50% on token costs. Sounds interesting, right? Let me walk you through what it is, why people are excited about it, and how you can start using it today.

For the last two decades, JSON has been the standard language of web data, human-readable, easy to parse, and supported everywhere. But when it comes to AI systems where every token matters, JSON’s structure can become unnecessarily heavy and expensive. TOON offers a smarter, leaner alternative.

What Exactly is TOON?

TOON stands for Token Oriented Object Notation. Think of it as JSON’s more efficient cousin, specifically designed for talking to AI models.

JSON has been around since the early 2000s, thanks to Douglas Crockford. It’s great for web APIs and human readability. But here’s the thing: JSON wasn’t built for the AI era. It’s full of curly braces, quotation marks, and repeated key names. All of that eats up tokens.

Let me show you what I mean with a quick example.

Here’s some user data in JSON:

{
  "users": [
    { "id": 1, "name": "Ayu", "role": "admin" },
    { "id": 2, "name": "Iti", "role": "user" }
  ]
}

Now, here’s the exact same data in TOON:

users[2]{id,name,role}:
  1,Ayu,admin
  2,Iti,user

See the difference? No quotes. No braces. No repeated keys. Just clean, structured data that AI models can understand perfectly well.

The TOON version uses significantly fewer tokens while keeping everything organized and readable.

Why Should You Care About TOON Right Now?

Here’s the deal: AI models like ChatGPT, Claude, and Gemini charge based on tokens. Every API call costs you based on how many tokens you send in and receive back.

Imagine you’re building an app that sends product catalogs to an AI model. If your catalog has 500 products in JSON format, you might be burning through thousands of unnecessary tokens just on formatting characters.

TOON solves this by stripping away the fluff. Here are the main benefits:

Cost savings: 30-50% fewer tokens means your AI bills go down proportionally. If you are spending $500/month on AI API calls, TOON could potentially save you $150-250.

Faster processing: Less data to send means faster API responses. Your users get results quicker.

Cleaner structure: TOON’s tabular format is actually closer to how AI models naturally process structured data internally.

It works everywhere: There are already libraries for JavaScript, TypeScript, Python, and more languages are coming.

I’m not saying TOON will replace JSON tomorrow. But for AI-specific use cases, it’s a smart optimization that’s hard to ignore.

Real World Examples: JSON vs TOON

Let me show you how different data structures translate between these two formats. This will help you understand when TOON makes sense.

Example 1: Basic Information

JSON version:

{ "name": "Iti", "age": 23, "city": "New York" }

TOON version:

name: Iti
age: 23
city: New York

Pretty straightforward, right? TOON drops the curly braces and quotes. For simple objects like this, the savings might seem small, but multiply this by thousands of records, and it adds up fast.

Example 2: Simple Lists

JSON version:

{ "colors": ["red", "green", "blue"] }

TOON version:

colors[3]: red,green,blue

The [3] tells you there are three items. Then it’s just comma-separated values. Clean and efficient.

Example 3: Multiple Records (This is Where TOON Shines)

JSON version:

{
  "employees": [
    { "id": 101, "name": "Ayu", "department": "Engineering" },
    { "id": 102, "name": "Revathi", "department": "Marketing" },
    { "id": 103, "name": "Iti", "department": "Engineering" }
  ]
}

TOON version:

employees[3]{id,name,department}:
  101,Ayu,Engineering
  102,Revathi,Marketing
  103,Iti,Engineering

This is where you really see the difference. The TOON version declares the schema once ({id,name,department}) and then just lists the data. No repeated key names. No extra brackets around each employee.

Example 4: Nested Data

JSON version:

{
  "company": {
    "name": "TechCorp",
    "location": "San Francisco",
    "stats": { 
      "employees": 150, 
      "founded": 2018 
    }
  }
}

TOON version:

company:
  name: TechCorp
  location: San Francisco
  stats:
    employees: 150
    founded: 2018

TOON uses indentation to show nesting, similar to how YAML works. It’s actually quite readable once you get used to it.

Example 5: Complex Nested Arrays

JSON version:

{
  "projects": [
    {
      "title": "Website Redesign",
      "team": [
        { "id": 1, "name": "Ayu" },
        { "id": 2, "name": "Iti" }
      ]
    }
  ]
}

TOON version:

projects[1]:
  - title: Website Redesign
    team[2]{id,name}:
      1,Ayu
      2,Iti

OR

projects[1]:
  - title: Website Redesign
    team[2]:
      - id: 1, name: Ayu
      - id: 2, name: Iti

Even with complex nesting, TOON keeps things compact and understandable.

How to Use TOON in JavaScript/TypeScript Projects

Good news: you don’t need to write TOON by hand. There’s an official NPM package that handles all the conversion for you.

First, install the package:

npm install @toon-format/toon

Or if you’re using yarn or pnpm:

yarn add @toon-format/toon
# or
pnpm install @toon-format/toon

Converting JSON to TOON

Here’s how simple it is to encode your JSON data into TOON format:

import { encode } from "@toon-format/toon";

const customerData = {
  customers: [
    { id: 1, name: "Ayu", plan: "premium" },
    { id: 2, name: "Revathi", plan: "basic" },
    { id: 3, name: "Iti", plan: "premium" }
  ]
};

const toonFormat = encode(customerData);
console.log(toonFormat);

Output:

customers[3]{id,name,plan}:
  1,Ayu,premium
  2,Revathi,basic
  3,Iti,premium

Converting TOON Back to JSON

Need to convert TOON data back to regular JSON? Just use the decode method:

import { decode } from "@toon-format/toon";

const toonData = `
customers[3]{id,name,plan}:
  1,Ayu,premium
  2,Revathi,basic
  3,Iti,premium
`;

const jsonObject = decode(toonData);
console.log(JSON.stringify(jsonObject, null, 2));

Output:

{
  "customers": [
    { "id": 1, "name": "Ayu", "plan": "premium" },
    { "id": 2, "name": "Revathi", "plan": "basic" },
    { "id": 3, "name": "Iti", "plan": "premium" }
  ]
}

It’s that easy. The library handles all the heavy lifting.

Using TOON in Python Projects

Python developers aren’t left out. There’s a great package called python-toon that works similarly.

First, install it:

pip install python-toon

If you’re using a virtual environment (which you should be), activate it first:

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install python-toon

Encoding JSON to TOON in Python

from toon import encode

# Sample data about a course
course = {
    "title": "Web Development Bootcamp",
    "duration": 12,
    "level": "beginner",
    "students": 450
}

toon_output = encode(course)
print(toon_output)

Output:

title: Web Development Bootcamp
duration: 12
level: beginner
students: 450

Decoding TOON Back to JSON in Python

from toon import decode

toon_string = """
title: Web Development Bootcamp
duration: 12
level: beginner
students: 450
"""

python_dict = decode(toon_string)
print(python_dict)

Output:

{
    "title": "Web Development Bootcamp",
    "duration": 12,
    "level": "beginner",
    "students": 450
}

When You Should Stick With JSON

Let me be honest with you: TOON isn’t a silver bullet. There are plenty of situations where JSON is still the better choice.

Use JSON when:

  • You’re building regular web APIs that don’t involve AI
  • Your data has irregular structures (different objects with different fields)
  • You need strict validation with JSON Schema
  • You’re dealing with deeply nested, complex data structures
  • Your team is already comfortable with JSON and the token cost isn’t a concern
  • You’re working with tools and systems that only understand JSON

Use TOON when:

  • You’re sending data to AI models (ChatGPT, Claude, etc.)
  • You have large datasets with consistent structures
  • Token costs are adding up and impacting your budget
  • You’re building AI agents that need to process lots of structured data
  • Response time matters and you want to reduce payload sizes

Honestly, a hybrid approach makes the most sense for many projects. Keep using JSON for your regular APIs and database operations. Convert to TOON specifically when you’re preparing data for AI model interactions.

What’s Next for TOON?

TOON is still pretty new, but it’s gaining traction quickly. I’ve been watching the developer community embrace it for several use cases:

AI training data: Researchers are using TOON to reduce token overhead when fine-tuning language models.

AI agent frameworks: Frameworks that orchestrate multiple AI agents are adopting TOON for inter-agent communication.

Serverless AI applications: Where every millisecond and every token counts, TOON provides measurable benefits.

Model Context Protocol (MCP): TOON is being explored for faster data exchange between AI workflow engines.

The thing is, we might be seeing the beginning of a new standard. Just like JSON became the de facto format for web APIs, TOON could become the standard for AI data interchange.

Is it going to happen overnight? Probably not. But if you’re building AI applications today, it’s worth keeping TOON on your radar.

My Honest Take

I’ll be straight with you: when I first heard about TOON, I was skeptical. “Another data format? Really?” But after actually using it in a few projects, I get it.

The token savings are real. For a chatbot I built that processes customer support tickets, switching from JSON to TOON cut my OpenAI API costs by about 35%. That’s significant when you’re processing thousands of tickets per month.

The learning curve is minimal. If you understand JSON and have worked with indentation-based formats like YAML or Python, TOON will feel familiar within an hour.

That said, I wouldn’t rush to replace JSON everywhere. That would be premature. But for AI-specific workflows? Absolutely worth trying.

Getting Started Today

If you want to experiment with TOON, here’s what I recommend:

  1. Pick a small AI feature in your app that uses structured data
  2. Install the TOON library for your language (JavaScript or Python)
  3. Try converting your data to TOON before sending it to the AI model
  4. Compare the token usage and cost in your API logs
  5. Measure the difference and decide if it’s worth adopting more widely

Start small, measure the impact, and scale from there.

Wrapping Up

TOON is an interesting development in the AI space. It’s not revolutionary, but it is practical. In a world where AI costs are a real concern for many developers and businesses, optimizations like this matter.

Will TOON become as ubiquitous as JSON? Time will tell. But it’s solving a real problem right now: making AI interactions more efficient and affordable.

If you’re building AI applications, especially ones that send lots of structured data to language models, give TOON a try. You might be surprised by how much you can save.

Have you tried TOON yet? I’d love to hear about your experience with it. Drop a comment below and let’s discuss!

Leave a Reply

Your email address will not be published. Required fields are marked *