 # Token-Oriented Object Notation (TOON) [](https://github.com/toon-format/toon/actions) [](https://www.npmjs.com/package/@toon-format/toon) [](https://github.com/toon-format/spec) [](https://www.npmjs.com/package/@toon-format/toon) [](./LICENSE) **Token-Oriented Object Notation** is a compact, human-readable encoding of the JSON data model for LLM prompts. It provides a lossless serialization of the same objects, arrays, and primitives as JSON, but in a syntax that minimizes tokens and makes structure easy for models to follow. TOON combines YAML's indentation-based structure for nested objects with a CSV-style tabular layout for uniform arrays. TOON's sweet spot is uniform arrays of objects (multiple fields per row, same structure across items), achieving CSV-like compactness while adding explicit structure that helps LLMs parse and validate data reliably. For deeply nested or non-uniform data, JSON may be more efficient. The similarity to CSV is intentional: CSV is simple and ubiquitous, and TOON aims to keep that familiarity while remaining a lossless, drop-in representation of JSON for Large Language Models. Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input. > [!TIP] > TOON is production-ready, but also an idea in progress. Nothing's set in stone β help shape where it goes by contributing to the [spec](https://github.com/toon-format/spec) or sharing feedback. ## Table of Contents - [Why TOON?](#why-toon) - [Key Features](#key-features) - [When Not to Use TOON](#when-not-to-use-toon) - [Benchmarks](#benchmarks) - [Installation & Quick Start](#installation--quick-start) - [Playgrounds](#playgrounds) - [CLI](#cli) - [Format Overview](#format-overview) - [API](#api) - [Using TOON in LLM Prompts](#using-toon-in-llm-prompts) - [Syntax Cheatsheet](#syntax-cheatsheet) - [Other Implementations](#other-implementations) - [π Full Specification](https://github.com/toon-format/spec/blob/main/SPEC.md) ## Why TOON? AI is becoming cheaper and more accessible, but larger context windows allow for larger data inputs as well. **LLM tokens still cost money** β and standard JSON is verbose and token-expensive. TOON offers a more compact alternative:
| JSON | TOON |
|---|---|
| ```json { "context": { "task": "Our favorite hikes together", "location": "Boulder", "season": "spring_2025" }, "friends": ["ana", "luis", "sam"], "hikes": [ { "id": 1, "name": "Blue Lake Trail", "distanceKm": 7.5, "elevationGain": 320, "companion": "ana", "wasSunny": true }, { "id": 2, "name": "Ridge Overlook", "distanceKm": 9.2, "elevationGain": 540, "companion": "luis", "wasSunny": false }, { "id": 3, "name": "Wildflower Loop", "distanceKm": 5.1, "elevationGain": 180, "companion": "sam", "wasSunny": true } ] } ``` | ```toon context: task: Our favorite hikes together location: Boulder season: spring_2025 friends[3]: ana,luis,sam hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}: 1,Blue Lake Trail,7.5,320,ana,true 2,Ridge Overlook,9.2,540,luis,false 3,Wildflower Loop,5.1,180,sam,true ``` |