toon
toon-format/toon
π Token-Oriented Object Notation (TOON) β Compact, human-readable, schema-aware JSON for LLM prompts. Spec, benchmarks, TypeScript SDK.
π Token-Oriented Object Notation (TOON) β Compact, human-readable, schema-aware JSON for LLM prompts. Spec, benchmarks, TypeScript SDK.
Categories
Tags
Similar tools
ECC
affaan-m/ECC
affaan-m/ECC
ollama
ollama/ollama
Local inference runtime and CLI for open-weight large language models
prompts.chat
f/prompts.chat
f/prompts.chat
transformers
huggingface/transformers
huggingface/transformers
JavaGuide
Snailclimb/JavaGuide
Java guide for backend interviews & AI application development covering system design, LLMs, Agents, and RAG.
langflow
langflow-ai/langflow
Metadata derived from provided repository information.
Install
npm install toonREADME
Token-Oriented Object Notation (TOON)
Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow. It's intended for LLM input as a drop-in, lossless representation of your existing JSON.
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] The TOON format is stable, but also an idea in progress. Nothing's set in stone β help shape where it goes by contributing to the spec or sharing feedback.
Table of Contents
- Why TOON?
- Key Features
- When Not to Use TOON
- Benchmarks
- Installation & Quick Start
- Playgrounds
- Editor Support
- CLI
- Format Overview
- Using TOON with LLMs
- Documentation
- Other Implementations
- π Full Specification
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:
{
"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
}
]
}
YAML already conveys the same information with fewer tokens.
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 conveys the same information with even fewer tokens β combining YAML-like indentation with CSV-style tabular arrays:
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
Key Features
- π Token-Efficient & Accurate: TOON reaches 76.4% accuracy (vs JSON's 75.0%) while using ~40% fewer tokens in mixed-structure benchmarks across 4 models.
- π JSON Data Model: Encodes the same objects, arrays, and primitives as JSON with deterministic, lossless round-trips.
- π€οΈ **LLM-Frie