toon
🎒 Token-Oriented Object Notation (TOON) – compact, human-readable serialization of JSON data for LLM prompts. TypeScript SDK, CLI, benchmarks.
What is toon?
🎒 Token-Oriented Object Notation (TOON) – compact, human-readable serialization of JSON data for LLM prompts. TypeScript SDK, CLI, benchmarks.
Overview of toon
What it is
Token-Oriented Object Notation (TOON) is a compact, human-readable encoding of the JSON data model designed to minimize tokens and make structure easy for LLMs to follow. It combines YAML-style indentation for nested objects with CSV-style tabular forms for uniform data. TOON serves as a translation layer: use JSON programmatically, and encode it as TOON for LLM input – a drop-in, lossless representation of the same JSON data. The format is stable but still an idea in progress, with contributions welcome.
Key features
- Token-Efficient & Accurate: Matches JSON's retrieval accuracy with fewer tokens – see Benchmarks.
- JSON Data Model: Encodes the same objects, arrays, and primitives as JSON with deterministic, lossless round-trips.
- LLM-Friendly Guardrails:
[N]declares how many rows,{fields}how wide – so truncated or malformed output can't slip through. - Minimal Syntax: Uses indentation instead of braces and minimizes quoting, giving YAML-like readability with CSV-style compactness.
- Tabular Forms: Uniform objects – in an array or under keys – declare the field list once, then stream one row each.
- Multi-Language Ecosystem: Official implementations plus dozens of community ports, all targeting one spec with a shared conformance test suite.
Use cases
TOON is primarily used for encoding JSON data for LLM prompts, especially when data consists of arrays of uniform objects. It reduces token costs compared to JSON while maintaining or improving LLM comprehension accuracy per token. It is also suitable for data retrieval tasks where token efficiency matters. TOON is not recommended for deeply nested or non-uniform structures, purely tabular data where CSV is smaller, or latency-sensitive deployments where compact JSON may be faster.
Getting started
Try TOON on your own data without installation: bash cat data.json | npx @toon-format/cli --stats This prints the TOON representation alongside token savings. For programmatic use, the TypeScript SDK is available via npm. See the repository README for full installation and usage instructions.
License and pricing
The license is MIT. The project is open source with no stated pricing.
Based on the project's public README and repository metadata.