Token-Oriented Object Notation (TOON)

TOON is a compact, human-readable encoding of the JSON data model that minimizes tokens and keeps structure easy for models to follow. It is intended for LLM input as a drop-in, lossless representation of your existing JSON.

Why TOON?

JSON is verbose and token-expensive. TOON combines YAML-style indentation with a CSV-like table layout for uniform arrays, reducing token count while staying faithful to the original JSON structure.

Example: JSON → TOON

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
    }
  ]
}

TOON

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

Key Features

  • Token-efficient while keeping full JSON compatibility.
  • Deterministic, lossless round-trips back to JSON.
  • Tabular arrays declare fields once for compactness.
  • Explicit array lengths and column headers improve LLM parsing.
  • Minimal syntax with YAML-like readability.

When Not to Use TOON

  • Deeply nested, irregular structures where JSON can be smaller.
  • Pure tabular data where CSV is more compact.
  • Latency-critical systems that benefit from existing JSON pipelines.

Try It

Use the LangToon Playground to convert JSON or YAML into TOON and compare token savings.