# TOON: Save upto 60% on AI Agentic RAG Applications for FREE!

Source: https://www.youtube.com/watch?v=lfnJXlgpJT0
Recap page: https://rapidrecap.app/video/lfnJXlgpJT0
Generated: 2025-11-17T14:02:39.042+00:00

---
## Quick Overview

The TOON format, or Token-Oriented Object Notation, is a free, open-source, client-side data serialization format designed to significantly reduce token usage in LLM prompts, achieving 30-60% fewer tokens compared to standard JSON, which saves costs and improves RAG application efficiency, as demonstrated by TOON achieving 73.9% retrieval accuracy against JSON's 69.7% in benchmarks.

**Key Points:**
- TOON (Token-Oriented Object Notation) reduces LLM prompt token usage by 30-60% compared to formatted JSON, leading to cost savings for AI applications.
- TOON achieves 73.9% retrieval accuracy in benchmarks, outperforming standard JSON's 69.7% accuracy using fewer tokens.
- Key features of TOON include minimal syntax (fewer punctuation marks), indentation-based structure (like YAML), tabular arrays, and optional key folding.
- The demonstration showed API calls converting JSON to TOON resulted in 92 JSON tokens reducing to 58 TOON tokens (37% saved).
- TOON handles complex data structures, including nested objects and various data types like datetime, Decimal, and UUID, which are encoded efficiently.
- The library offers Python and TypeScript packages for easy integration, including an `encode` function and command-line interface (CLI) for direct file conversion.

![Screenshot at 00:05: The visual comparison shows a JSON structure taking 92 tokens being converted into the TOON format using only 58 tokens, resulting in a 37% token saving.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-05.png)

**Context:** This video introduces TOON (Token-Oriented Object Notation), a new, open-source data serialization format explicitly designed to optimize data representation for Large Language Model (LLM) prompts. The core problem addressed is the high token cost associated with traditional formats like JSON when dealing with large datasets in Retrieval Augmented Generation (RAG) applications. The presenter demonstrates the format's token efficiency and accuracy advantages over JSON, YAML, and XML through live coding and benchmarking comparisons.

## Detailed Analysis

The creator introduces TOON as a Token-Optimized Data Conversion format, emphasizing its 100% client-side operation with zero data collection, aiming to reduce LLM token usage by up to 60% and save on API costs. Benchmarks demonstrate TOON's superior efficiency: it achieves 73.9% retrieval accuracy compared to JSON's 69.7% while using significantly fewer tokens (e.g., 2,744 TOON tokens vs. 4,545 JSON tokens for a specific test). Key features include token efficiency, LLM-friendly guardrails, minimal syntax (removing brackets and quotes), YAML-like indentation, tabular arrays, and optional key folding. The video provides practical demonstrations using Python (importing `toon_python` and using the `encode` function) and TypeScript, showing how simple JSON data is converted into the compact TOON structure. Advanced data types (datetime, Decimal, UUID, binary) are also handled correctly by the encoder. Furthermore, the CLI tool allows direct conversion of files (e.g., `npx @toon-format/cli input.json -o output.toon`), proving its utility across various development environments.

### Token Efficiency Comparison

- JSON initial input used 92 tokens, while TOON format resulted in 58 tokens, achieving a 37% saving
- API response conversion showed JSON (128 tokens) reduced to TOON (66 tokens), saving 48%
- CLI conversion of JSON input resulted in TOON output saving 58.4% compared to Pretty JSON baseline.

### TOON Key Features

- Token-efficient (30-60% fewer tokens on large uniform arrays)
- LLM-friendly guardrails (explicit lengths/fields)
- Minimal syntax (removes redundant punctuation)
- Indentation-based structure (like YAML)
- Tabular arrays support
- Optional key folding.

### Python Integration Example

- Imports `encode` from `toon_python`
- Defines basic JSON data for Alice
- Uses `encode(data)` to generate TOON output
- Demonstrates how to use `EncodeOptions` to customize indentation (4), delimiter (PIPE), and length marker (#).

### Advanced Data Handling

- TOON successfully encodes complex structures including nested objects (user data), lists (roles, items), and advanced types like datetime, Decimal, UUID, and binary data.

### JavaScript/TypeScript Integration

- Imports `encode` from `@toon-format/toon`
- Defines data with an array of user objects
- Calls `console.log(encode(data))` to demonstrate usage.

### CLI Usage

- Executes `npx @toon-format/cli input.json -o output.toon` to convert a file directly, demonstrating command-line utility for quick serialization.

![Screenshot at 00:01: Side-by-side comparison showing a 92-token JSON structure transforming into a 58-token TOON structure, highlighting the token reduction achieved by TOON.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-01.png)
![Screenshot at 00:11: Demonstration of API request latency comparison: without TOON, the request took 144ms; with TOON enabled, it dropped to 19ms.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-11.png)
![Screenshot at 00:28: GitHub repository overview for 'toon-format', showing significant community interest with 16.9K stars.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-28.png)
![Screenshot at 00:35: Slide detailing TOON's key features, emphasizing token efficiency \(30-60% fewer tokens\) and LLM-friendliness.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-35.png)
![Screenshot at 00:54: Benchmark comparison chart showing TOON achieving 73.9% accuracy with 2,744 tokens, superior to JSON's 69.7% accuracy with 4,545 tokens.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-00-54.png)
![Screenshot at 01:01: Python code snippet showing the basic use of the encode function from toon\_python to convert a simple dictionary.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-01-01.png)
![Screenshot at 02:14: Landing page graphic summarizing TOON's value proposition: 60% Token Reduction, Fast results, and Safe/Private operation.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-02-14.png)
![Screenshot at 02:25: Comparison chart across multiple formats \(Pretty JSON, JSON, YAML, TOON, XML\) for a simple dataset, visually confirming TOON's minimal token count \(32 tokens\) compared to others.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-02-25.png)
![Screenshot at 03:58: Terminal output showing the result of running the advanced Python script, displaying basic encoding, custom options encoding \(using PIPE delimiter and # marker\), and handling of nested structures.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-03-58.png)
![Screenshot at 05:31: Terminal output after running the advanced script, displaying the TOON output for nested structures and advanced data types, confirming successful encoding.](https://ss.rapidrecap.app/screens/lfnJXlgpJT0/00-05-31.png)
