What is TOON and Why Should You Use It?

In the world of web development and data exchange, JSON (JavaScript Object Notation) has long been the king. It's lightweight, easy to read, and supported by virtually every programming language. However, as Large Language Models (LLMs) become more prevalent, the need for a more efficient data format has emerged. This is where TOON (Token Optimized Object Notation) comes in.

What is TOON?

TOON is a data serialization format designed specifically for LLMs. It's a superset of JSON, meaning any valid JSON is also valid TOON. However, TOON introduces several new features that make it more efficient for LLMs to process, resulting in lower token usage and faster response times.

Why Should You Use It?

There are several key benefits to using TOON over JSON when working with LLMs:

Programmatic Usage with @toon-format/toon

For developers looking to integrate TOON into their applications, we provide an open-source library called @toon-format/toon. This library makes it easy to convert JSON to TOON programmatically, allowing you to automate the process and build powerful data pipelines.

Installation

You can install the library using npm:

npm install @toon-format/toon

Example Usage

Here's a simple example of how to use the library to convert a JSON object to TOON:

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

const json = {
  name: 'John Doe',
  age: 30,
  isStudent: false,
  courses: [
    { title: 'History', credits: 3 },
    { title: 'Math', credits: 4 }
  ]
};

const toon = encode(json);
console.log(toon);

Benefits of Programmatic Use

Using the @toon-format/toon library offers several advantages:

How to Get Started

Ready to start using TOON? Here's how you can get started:

  1. Try it out: Use our free online converter to see how much you can save.
  2. Install the library: Install the @toon-format/toon library to start using TOON in your applications.
  3. Read the docs: Check out the official documentation to learn more about the library and its features.

Conclusion

While JSON is still a great choice for many applications, TOON is the clear winner when it comes to working with LLMs. Its reduced token usage, faster processing times, and improved readability make it the ideal choice for any developer looking to get the most out of their LLM.

Back to Blog