JSON vs TOON.
Is JSON really dead for LLM calls ?
JSON is universal and excellent for nested data. TOON, in contrast, is a token optimized alternative built only for flat, tabular data; it slashes token usage by up to 60% for that specific use case.
Here’s how it works under the hood:
>TOON analyzes an array of uniform objects (where all items have the same keys).
>It declares the field keys (id, name, age) only once in a header.
>It streams the array items like a CSV, using indentation for structure.
>This eliminates repeating keys, quotes, and braces for every single row.
>For nested or non uniform data, it falls back to a YAML like structure, losing its efficiency.
How It Differs from JSON:
>JSON's syntax (braces, brackets, quotes) is excellent for handling nested objects and complex APIs.
>TOON's syntax (indentation, headers, minimal quotes) is built for flat tables and LLM prompts.
>JSON has a mature, universal ecosystem.
>TOON has an emerging, LLM specific ecosystem.
>It is inefficient for deep nesting; JSON handles it perfectly.
Why it matters:
>Up to 60% fewer tokens for tabular data
>Reduced LLM API costs.
>Faster prompt processing.
>Fits more tabular data into the LLM context window.
When to use it:
>LLM prompts containing flat, tabular data.
>Uniform arrays of objects (like database results).
>Always flatten nested structures before converting for best results.
>When you need to send large, simple tables to an LLM.
And no, JSON is not dead for LLM calls.