TOON is a compact, lossless encoding of the JSON data model designed for LLM prompts. It uses YAML-style indentation for nested objects and a CSV-style tabular layout for uniform arrays — up to 60% fewer tokens than JSON.
TOON's biggest win: arrays of uniform objects collapse into a header row [N,]{fields}: followed by comma-separated data rows — just like CSV but with explicit structure.
Strings are only quoted when necessary — when they look like a number, boolean, null, contain the delimiter, have leading/trailing whitespace, or are empty. Everything else is written bare.
TOON achieves 76% LLM accuracy vs JSON's 75% on data-retrieval benchmarks, while using ~40% fewer tokens. Best used as a translation layer: keep JSON for APIs, send TOON to LLMs.
Nested objects use indentation instead of curly braces. Each key-value pair is written as key: value, and nested objects add one level of indentation (2 spaces by default).
When all objects in an array share the same primitive-valued fields, TOON writes a header [N,]{f1,f2,f3}: followed by one comma-separated row per object. This is the biggest source of token savings.
Yes. TOON encodes the same objects, arrays, and primitives as JSON. You can round-trip JSON → TOON → JSON without any data loss. Types are preserved through TOON's quoting rules.
Use TOON when sending structured data to an LLM as context or input. The token savings directly reduce API cost and allow more data to fit in the context window. Keep JSON for programmatic APIs, databases, and anywhere that requires strict interoperability.