BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News New Token-Oriented Object Notation (TOON) Hopes to Cut LLM Costs by Reducing Token Consumption

New Token-Oriented Object Notation (TOON) Hopes to Cut LLM Costs by Reducing Token Consumption

Listen to this article -  0:00

The recently released Token-Oriented Object Notation (TOON) aims to be a schema-aware alternative to JSON that significantly reduces token consumption at a similar level of accuracy. While the existence and quantity of saved tokens depend on the data shape, some benchmarks show that TOON may use 40% fewer tokens in some cases than JSON, potentially resulting in LLM and inference cost savings.

TOON self-describes as a compact, human-readable encoding of the JSON data model for LLM prompts.

Consider the following JSON:

{
  "context": {
    "task": "Our favorite hikes together",
    "location": "Boulder",
    "season": "spring_2025"
  },
  "friends": ["ana", "luis", "sam"],
  "hikes": [
    {
      "id": 1,
      "name": "Blue Lake Trail",
      "distanceKm": 7.5,
      "elevationGain": 320,
      "companion": "ana",
      "wasSunny": true
    },
    {
      "id": 2,
      "name": "Ridge Overlook",
      "distanceKm": 9.2,
      "elevationGain": 540,
      "companion": "luis",
      "wasSunny": false
    },
    {
      "id": 3,
      "name": "Wildflower Loop",
      "distanceKm": 5.1,
      "elevationGain": 180,
      "companion": "sam",
      "wasSunny": true
    }
  ]
}

In the TOON format, the same data becomes:

context:
  task: Our favorite hikes together
  location: Boulder
  season: spring_2025

friends[3]: ana,luis,sam

hikes[3]{id,name,distanceKm,elevationGain,companion,wasSunny}:
  1,Blue Lake Trail,7.5,320,ana,true
  2,Ridge Overlook,9.2,540,luis,false
  3,Wildflower Loop,5.1,180,sam,true

Running this example in an online playground will show a 55% reduction in tokens vs. pretty-printed JSON, 25% vs. compact JSON, and 38% vs. YAML.

 

As the previous example showcases, TOON combines YAML (for nested objects) and CSV (for uniform arrays) layouts to save tokens. However, for non-uniform data, JSON may be more efficient. For deeply nested objects, YAML may be more token-efficient. For flat datasets, CSV remains the most compact format. TOON adds a small overhead (~5%) with field headers and array declarations, in order to improve LLM accuracy.

Johann Schopplich explained on X:

“Does token efficiency hurt accuracy?”
No :) TOON hits 99.4% accuracy on GPT 5 Nano while using 46% fewer tokens.
Tested across ~160 questions and 3 LLMs with semantic validation.
I think explicit lengths + field lists = fewer mistakes.

Readers may review TOON’s specifications, documentation, online playgrounds, and run their own efficiency and accuracy benchmarks. In latency-critical applications, developers should compare Time To First Token and tokens per second in both formats.

The reference implementation in TypeScript/JavaScript is maintained at github.com/toon-format/toon. The reference implementation includes a complete encoder and decoder, CLI tools for JSON-to-TOON conversion, and performance benchmarks. TOON 1.0 was released under the MIT license two weeks ago.

About the Author

Rate this Article

Adoption
Style

BT