TOON
lastmod 2025-11-19created 2025-11-191 edits
A token-efficient data serialization format for LLM input
About
- Token-Oriented Object Notation
- A serialization format designed to reduce token usage when feeding data to an LLM
- Represents JSON data losslessly while achieving both token efficiency and readability
- A hybrid format combining YAML's indentation-based structure with CSV's tabular layout
- For deeply nested or non-uniform data, JSON is more efficient
- Declares array length ([N]) and field definitions ({id,name,role}) to improve structure recognition
- Indentation-based hierarchy; supports CSV-like row-by-row data streams
- Options include automatic format detection, delimiter selection (,, \t, |), and token savings statistics output
- encode() serializes JSON, decode() deserializes
- Options for indentation, delimiter, and length marker (#)
- Slightly larger than CSV, but structural validation improves LLM reliability
- Strings are quoted only when needed; automatically quoted if they contain the delimiter
- Numbers, booleans, dates, etc. are converted to LLM-friendly forms
- Official: Python, Rust (in development)
- Community: Go, Java, Swift, C++, .NET, Ruby, etc.