TOON (Token-Oriented Object Notation) is a data format specifically designed to minimize token usage for Large Language Models (LLMs). It reduces the verbosity of JSON by using a tabular structure for arrays of objects and indentation for nesting, significantly lowering API costs and context window usage.
Basic Structure
TOON replaces repetitive keys in arrays with a single header row and uses indentation instead of braces and brackets.
Example
users:
[3]
{id,name,role}
1,"Alice","Admin"
2,"Bob","User"
3,"Charlie","User"
config:
env: "production"
retries: 3Key Features of TOON
- Tabular Arrays: Arrays of objects are represented as a table with a header row
{key1,key2}, eliminating repeated keys for every item. - Token Efficiency: By removing excessive quotes, braces, and repeated keys, TOON can reduce token count by 30-60% compared to JSON.
- Clean Syntax: Uses indentation to define structure (similar to YAML) and removes unnecessary punctuation.
- LLM Native: Designed to be easily parsed and generated by AI models, optimizing for their token-based processing.
TOON vs JSON
- Efficiency: TOON is significantly more compact for lists of data, saving tokens.
- Readability: The tabular format is often easier for humans to scan than a long list of JSON objects.
- Usage: JSON is for general web APIs; TOON is specialized for LLM interactions (prompts and responses).
On FormatJSONOnline, you can use the TOON Formatter to format and validate TOON data, or the JSON to TOON Converter to transform your JSON data into this efficient format.