What is TOON?

An overview of the Text-Object Oriented Notation format.

The Core Idea

TOON (Text-Object Oriented Notation) is a data serialization format designed to be both human-readable and token-efficient for language models. It combines the structural clarity of S-expressions with a syntax that is less verbose than JSON, making it an ideal choice for prompts, configurations, and lightweight data exchange.

It aims to reduce the number of structural characters (like `, `, `,`, `:`) that are common in formats like JSON, which can consume a significant portion of a language model's context window.

JSON vs. TOON

JSON Example:

{
  "user": {
    "id": 123,
    "name": "Jane Doe"
  }
}

TOON Equivalent:

(user (id 123) (name "Jane Doe"))

Key Advantages

  • Token Efficiency: Fewer structural characters means more space for meaningful data in your prompts.
  • Human Readability: The clean, indented structure is easy to read and write manually.
  • Simplicity: A minimal set of rules for representing objects, arrays, and primitive types.
  • Natural for AI: The structure is easily understood by large language models, often requiring less explicit instruction for parsing.