Skip to content
Search

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
  • Structure optimized for uniform arrays of objects; removes repeated keys for 30–60% token savings
    • 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
  • Includes explicit structural information so LLMs can reliably parse and validate the data
    • Declares array length ([N]) and field definitions ({id,name,role}) to improve structure recognition
  • Minimal syntax design with a concise grammar that drops unnecessary brackets, quotes, and punctuation
    • Indentation-based hierarchy; supports CSV-like row-by-row data streams
  • Bidirectional JSON ↔ TOON conversion via a CLI tool
    • Options include automatic format detection, delimiter selection (,, \t, |), and token savings statistics output
  • API structure
    • encode() serializes JSON, decode() deserializes
    • Options for indentation, delimiter, and length marker (#)
  • Benchmarks show an average of 21–60% token savings over JSON and 73.9% LLM query accuracy
    • Slightly larger than CSV, but structural validation improves LLM reliability
  • Format rules
    • Strings are quoted only when needed; automatically quoted if they contain the delimiter
    • Numbers, booleans, dates, etc. are converted to LLM-friendly forms
  • Implementations in many languages
    • Official: Python, Rust (in development)
    • Community: Go, Java, Swift, C++, .NET, Ruby, etc.

See also

Favorite site

author Zer0 sitemap