Toon: Token-Oriented Object Notation (TOON) β compact, human-readable serialization of JSON dataβ¦
toon-format/toonπ Token-Oriented Object Notation (TOON) β compact, human-readable serialization of JSON data for LLM prompts. TypeScript SDK, CLI, benchmarks.
Evaluate and collect.
What the project says.
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. TOON combines YAML's indentation-based structure for nested objects with CSV-style tabular forms for uniform data. Its sweet spot is uniform objects β same fields across items, whether in an array or keyed by ID β reaching 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. Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input β a drop-in, lossless representation of the JSON you already have. [!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 - CLI - Using TOON with LLMs - Ecosystem - Documentation - Media Type & File Extension - π Full Specification Why TOON? LLM tokens cost money β and JSON spends a lot of them on structure. A weather forecast in TOON: The same data as JSON β 117 tokens against TOON's 66: Three things are happening at once in the TOON above. Two are forms β one rendering of a value, picked automatically from the data's shape β and the third is a header feature: - alerts[2]: frost,wind is inline form : a primitive array on its header line. - forecast[3]{day,β¦}: is tabular form : the field list is declared once in the header, then one row per element. - temp{min,max} inside that header is a nested field group : the uniform nested temp objects fold into the header while rows stay flat. The third form is keyed tabular , for objects whose values are uniform objects β config maps, feature flags, records by ID. The colon after the length ( [2:] ) marks it, and each row carries its own key: JSON TOON Anything that fits none of these β mixed types, non-uniform objects β falls back to the fourth form, list form : one - item per element, or a bare - for an empty object. Those four cover the shapes; the Format Overview covers the rest. [!TIP] Try it on your own data β no install required: It prints the TOON alongside what the conversion saved β on the weather forecast above, that's: 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. When Not to Use TOON TOON excels with arrays of uniform objects. Reach for something else when: - Structures are deeply nested or non-uniform (tabular eligibility β 0%) β compact JSON often wins outright. - Arrays are semi-uniform ( 40β60% eligibility) β savings shrink; stay on JSON if your pipeline already speaks it. - Data is purely tabular β CSV is smaller. TOON's 5β10% overhead buys declared lengths, field lists, and delimiter scoping, which is a reliability trade, not a size one. - Latency dominates β some deployments (notably local or quantized models) process compact JSON faster despite the higher token count. Measure TTFT and total time on your own setup. Benchmarks below quantify the token and accuracy trade-offs; latency is the one you have to measure yourself. Benchmarks Two tracks, so every comp...
Continue the conversation.
Comments, one-level replies, owner highlights, and discussion notifications are included with ORYNT membership.
Sign in with GitHub