AI Compare
​
​
ToolsArticlesServices
Best for
    All tools

    Sales

    AI tools for finding leads, qualifying them, preparing quotes, following up and keeping the CRM up to date.

    Marketing

    AI tools for content, social media, images, video, SEO and campaigns.

    Customer service

    AI tools for answering customer emails, chats and calls, handling requests and escalating the hard cases.

    Operations

    AI tools for running the daily work: workflows, scheduling, projects, purchasing and delivery.

    Finance

    AI tools for invoices, bookkeeping, reconciliation, spreadsheets and financial reporting.

    Management & Admin

    AI tools for owners, managers and office staff: planning, reports, documents, meetings, scheduling and everyday admin.

    HR

    AI tools for hiring, screening candidates, onboarding, training and answering employee questions.

    Legal & Compliance

    AI tools for reviewing contracts, tracking deadlines and preparing compliance work for a qualified person to check.

    IT & Development

    AI tools for developers and IT teams: coding, AI models, agents, infrastructure and integrations.

Find AI tools for your team
AllAssistantsWriting & DocsImagesVideoAudioAI AgentsAutomationCode
← Back to tools

β€’

2025-10-22

toon logo

toon

Not rated yet

25K GitHub stars

Type:

Framework

Platforms:

Github

Task:

Summarize contentTranslate textBuild AI appsAnalyze dataCreate spreadsheets

Best for:

MarketingCustomer serviceFinanceIT & Development
Visit websiteView on GitHub

Pricing


Pricing information has not been added yet.

Overview

TOON, or Token-Oriented Object Notation, is a compact, human-readable encoding for the JSON data model designed to reduce token usage when structured data is passed to language models. It combines indentation-based nesting similar to YAML with CSV-like tabular forms for repeated records, making regular collections especially compact while preserving a structure that models can follow.

The format is aimed at situations where applications need to place substantial structured context inside prompts without paying the full token cost of conventional JSON. It is particularly effective for arrays or keyed collections whose objects share the same fields, while still supporting nested objects and other common JSON-style structures.

The repository contains the TOON implementation and links to the broader specification and package ecosystem. It is useful for developers building LLM applications, agents, data pipelines, or prompt infrastructure where structured-data readability and context-window efficiency both matter.

README

Summary card: JSON encodes to TOON for LLM prompts, with token and accuracy benchmarks

Token-Oriented Object Notation (TOON)

CI npm version SPEC v4.1 npm downloads (total) License: MIT

Token-Oriented Object Notation is a compact, human-readable encoding of the JSON data model that minimizes tokens and makes structure easy for models to follow.

TOON combines YAML's indentation-based structure for nested objects with CSV-style tabular forms for uniform data. Its sweet spot is uniform objects – same fields across items, whether in an array or keyed by ID – reaching CSV-like compactness while adding explicit structure that helps LLMs parse and validate data reliably. For deeply nested or non-uniform data, JSON may be more efficient.

Think of it as a translation layer: use JSON programmatically, and encode it as TOON for LLM input – a drop-in, lossless representation of the JSON you already have.

[!TIP] The TOON format is stable, but also an idea in progress. Nothing's set in stone – help shape where it goes by contributing to the spec or sharing feedback.

Table of Contents

  • Why TOON?
  • Key Features
  • When Not to Use TOON
  • Benchmarks
  • Installation & Quick Start
  • CLI
  • Using TOON with LLMs
  • Ecosystem
  • Documentation
  • Media Type & File Extension
  • Other Implementations
  • πŸ“‹ Full Specification

Why TOON?

LLM tokens cost money – and JSON spends a lot of them on structure. A weather forecast in TOON:

location:
  city: Berlin
  country: DE
  units: metric
alerts[2]: frost,wind
forecast[3]{day,temp{min,max},condition,rainChance}:
  Mon,-2,4,snow,80
  Tue,1,7,cloudy,20
  Wed,3,11,sunny,5

The same data as JSON – ~117 tokens against TOON's ~66:

{
  "location": {
    "city": "Berlin",
    "country": "DE",
    "units": "metric"
  },
  "alerts": [
    "frost",
    "wind"
  ],
  "forecast": [
    {
      "day": "Mon",
      "temp": {
        "min": -2,
        "max": 4
      },
      "condition": "snow",
      "rainChance": 80
    },
    {
      "day": "Tue",
      "temp": {
        "min": 1,
        "max": 7
      },
      "condition": "cloudy",
      "rainChance": 20
    },
    {
      "day": "Wed",
      "temp": {
        "min": 3,
        "max": 11
      },
      "condition": "sunny",
      "rainChance": 5
    }
  ]
}

Three things are happening at once in the TOON above. Two are forms – one rendering of a value, picked automatically from the data's shape – and the third is a header feature:

  • alerts[2]: frost,wind is inline form: a primitive array on its header line.
  • forecast[3]{day,…}: is tabular form: the field list is declared once in the header, then one row per element.
  • temp{min,max} inside that header is a nested field group: the uniform nested temp objects fold into the header while rows stay flat.

The third form is keyed tabular, for objects whose values are uniform objects – config maps, feature flags, records by ID. The colon after the length ([2:]) marks it, and each row carries its own key:

JSONTOON
{
  "environments": {
    "production": { "region": "eu-central-1", "replicas": 6, "debug": false },
    "staging": { "region": "eu-central-1", "replicas": 2, "debug": true }
  }
}
environments[2:]{region,replicas,debug}:
  production: eu-central-1,6,false
  staging: eu-central-1,2,true

Anything that fits none of these – mixed types, non-uniform objects – falls back to the fourth form, list form: one - item per element, or a bare - for an empty object. Those four cover the shapes; the Format Overview covers the rest.

[!TIP] Try it on your own data – no install required:

cat data.json | npx @toon-format/cli --stats

It prints the TOON alongside what the conversion saved – on the weather forecast above, that's:

β„Ή Token estimates: ~117 (JSON) β†’ ~66 (TOON)
βœ” Saved ~51 tokens (-43.6%)

Key Features

  • πŸ“Š Token-Efficient & Accurate: Matches JSON's retrieval accuracy while using 42.6% fewer tokens – see Benchmarks.
  • πŸ” JSON Data Model: Encodes the same objects, arrays, and primitives as JSON with deterministic, lossless round-trips.
  • πŸ›€οΈ LLM-Friendly Guardrails: Explicit [N] lengths and {fields} field lists give models a clear schema to follow, improving parsing reliability.
  • πŸ“ Minimal Syntax: Uses indentation instead of braces and minimizes quoting, giving YAML-like readability with CSV-style compactness.
  • 🧺 Tabular Forms: Uniform arrays of objects – and objects of uniform objects – collapse into tables that declare the field list once and stream row values line by line.
  • 🌐 Multi-Language Ecosystem: Spec-driven implementations in many languages.

When Not to Use TOON

TOON excels with uniform arrays of objects. Reach for something else when:

  • Structures are deeply nested or non-uniform (tabular eligibility β‰ˆ 0%) – compact JSON often wins outright.
  • Arrays are semi-uniform (~40–60% eligibility) – savings shrink; stay on JSON if your pipeline already speaks it.
  • Data is purely tabular – CSV is smaller. TOON's ~5–10% overhead buys declared lengths, field lists, and delimiter scoping, which is a reliability trade, not a size one.
  • Latency dominates – some deployments (notably local or quantized models) process compact JSON faster despite the higher token count. Measure TTFT and total time on your own setup.

Benchmarks below quantify the token and accuracy trade-offs; latency is the one you have to measure yourself.

Benchmarks

Two tracks, so every comparison is like-for-like:

  • Mixed-Structure Track: Nested and semi-uniform datasets (TOON vs JSON, YAML, XML). CSV is excluded – it cannot represent these structures without lossy flattening.
  • Flat-Only Track: Flat, fully tabular-eligible datasets, where CSV is a fair competitor.

Retrieval Accuracy

Benchmarks test LLM comprehension across different input formats using 244 data retrieval questions on 4 models.

Show Dataset Catalog

Dataset Catalog

DatasetRowsStructureCSV SupportEligibility
Uniform employee records100uniformβœ“100%
E-commerce orders with nested structures50nestedβœ—33%
Time-series analytics data60uniformβœ“100%
Top 100 GitHub repositories100uniformβœ“100%
Semi-uniform event logs75semi-uniformβœ—50%
Deeply nested configuration1deepβœ—0%
Valid complete dataset (control)20uniformβœ“100%
Array truncated: 3 rows removed from end20uniformβœ“100%
Extra rows added beyond declared length20uniformβœ“100%
Inconsistent field count (missing salary in row 10)20uniformβœ“100%
Missing required fields (no email in multiple rows)20uniformβœ“100%
Feature flags keyed by name40uniformβœ—100%
Contacts with nested address and plan groups50nestedβœ—100%

Structure classes:

  • uniform: All objects have identical fields with primitive values
  • semi-uniform: Mix of uniform and non-uniform structures
  • nested: Objects with nested structures (nested objects or arrays)
  • deep: Highly nested with minimal tabular eligibility

CSV Support: βœ“ (supported), βœ— (not supported – would require lossy flattening)

Eligibility: Percentage of arrays and keyed maps that qualify for TOON's tabular forms (uniform records whose fields are primitives or uniform nested objects folded into nested field groups)

Efficiency Ranking (Accuracy per 1K Tokens)

Each format ranked by efficiency (accuracy percentage per 1,000 tokens):

TOON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ   29.2 acc%/1K tok  β”‚  72.2%  Β±2.8 acc  β”‚  2,474 tokens
JSON compact   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘   23.8 acc%/1K tok  β”‚  69.0%  Β±2.9 acc  β”‚  2,892 tokens
YAML           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘   20.1 acc%/1K tok  β”‚  70.1%  Β±2.9 acc  β”‚  3,487 tokens
JSON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘   16.6 acc%/1K tok  β”‚  71.4%  Β±2.8 acc  β”‚  4,308 tokens
XML            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘   14.4 acc%/1K tok  β”‚  70.7%  Β±2.9 acc  β”‚  4,909 tokens

Efficiency score = (Accuracy % Γ· Tokens) Γ— 1,000. Higher is better.

[!TIP] TOON achieves 72.2% accuracy (vs JSON's 71.4%) while using 42.6% fewer tokens.

[!NOTE] CSV is excluded from the ranking as it only supports 109 of 244 questions (flat tabular data only). While CSV is highly token-efficient for simple tabular data, it cannot represent nested structures that other formats handle.

Accuracy on Flat Datasets

Every format answers the same 109 flat-dataset questions per model, so CSV can be compared on equal footing here.

FormatAccuracyCorrect/TotalAvg Tokens
toon63.1% Β±4.5275/4361,994
csv62.2% Β±4.5271/4361,851
json-pretty60.3% Β±4.6263/4363,950
xml60.1% Β±4.6262/4364,516
yaml59.9% Β±4.6261/4363,270
json-compact58.0% Β±4.6253/4362,718

Per-Model Accuracy

Accuracy across 4 LLMs on 244 data retrieval questions:

claude-haiku-4-5-20251001
β†’ TOON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘    65.6% Β±5.9 (160/244)
  JSON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘    63.5% Β±6.0 (155/244)
  XML            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    62.3% Β±6.0 (152/244)
  YAML           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    62.3% Β±6.0 (152/244)
  JSON compact   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    61.9% Β±6.0 (151/244)
  CSV            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    49.5% Β±9.2 (54/109)

gemini-3.6-flash
β†’ TOON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘    69.3% Β±5.8 (169/244)
  JSON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘    68.4% Β±5.8 (167/244)
  YAML           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘    67.6% Β±5.8 (165/244)
  XML            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘    65.2% Β±5.9 (159/244)
  JSON compact   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘    63.5% Β±6.0 (155/244)
  CSV            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    57.8% Β±9.1 (63/109)

gpt-5.4-nano
  XML            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    59.4% Β±6.1 (145/244)
  JSON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    57.4% Β±6.2 (140/244)
β†’ TOON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    57.0% Β±6.2 (139/244)
  JSON compact   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    54.9% Β±6.2 (134/244)
  YAML           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    54.5% Β±6.2 (133/244)
  CSV            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    46.8% Β±9.2 (51/109)

grok-4.5
β†’ TOON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    97.1% Β±2.2 (237/244)
  JSON           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    96.3% Β±2.5 (235/244)
  XML            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    95.9% Β±2.6 (234/244)
  YAML           β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    95.9% Β±2.6 (234/244)
  JSON compact   β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    95.5% Β±2.7 (233/244)
  CSV            β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    94.5% Β±4.5 (103/109)

[!NOTE] Accuracy figures include Wilson 95% confidence intervals (Β±); when two formats' intervals overlap, the difference between them is not statistically meaningful. CSV answers only the 109 flat-dataset questions, so its per-model cells cover a smaller, easier population than the other formats.

Performance by dataset and question type

Performance by Question Type

Question TypeTOONJSONXMLYAMLJSON compactCSV
Field Retrieval97.8%99.2%99.2%99.7%98.9%100.0%
Aggregation48.4%48.4%46.0%46.0%45.2%32.8%
Filtering38.0%41.1%37.5%40.1%38.0%33.3%
Structure Awareness90.3%84.0%84.0%79.2%78.5%82.8%
Structural Validation100.0%50.0%80.0%50.0%45.0%80.0%

Performance by Dataset

Uniform employee records
FormatAccuracyTokensCorrect/Total
csv64.6%2,336106/164
toon62.8%2,537103/164
json-compact62.2%3,919102/164
yaml64.0%4,982105/164
json-pretty62.2%6,326102/164
xml61.0%7,286100/164
E-commerce orders with nested structures
FormatAccuracyTokensCorrect/Total
json-compact70.7%6,875116/164
toon71.3%7,344117/164
yaml72.0%8,456118/164
json-pretty71.3%10,842117/164
xml74.4%12,180122/164
Time-series analytics data
FormatAccuracyTokensCorrect/Total
csv64.2%1,40877/120
toon63.3%1,59576/120
json-compact59.2%2,35171/120
yaml62.5%2,95175/120
json-pretty65.0%3,67878/120
xml62.5%4,38675/120
Top 100 GitHub repositories
FormatAccuracyTokensCorrect/Total
toon57.6%9,01776/132
csv54.5%8,72672/132
json-compact53.8%11,65071/132
yaml53.8%13,35071/132
json-pretty55.3%15,35073/132
xml53.8%17,30471/132
Semi-uniform event logs
FormatAccuracyTokensCorrect/Total
json-compact56.7%4,79368/120
toon60.8%5,81473/120
json-pretty60.0%6,75972/120
yaml55.0%5,79866/120
xml50.8%7,66861/120
Deeply nested configuration
FormatAccuracyTokensCorrect/Total
json-compact91.4%562106/116
yaml93.1%675108/116
toon91.4%669106/116
json-pretty94.8%918110/116
xml94.0%1,007109/116
Valid complete dataset (control)
FormatAccuracyTokensCorrect/Total
toon100.0%5664/4
json-compact100.0%7724/4
yaml100.0%9844/4
json-pretty100.0%1,2594/4
xml0.0%1,4410/4
csv0.0%4730/4
Array truncated: 3 rows removed from end
FormatAccuracyTokensCorrect/Total
csv100.0%4084/4
toon100.0%4984/4
xml100.0%1,2294/4
json-pretty0.0%1,0750/4
yaml0.0%8410/4
json-compact0.0%6600/4
Extra rows added beyond declared length
FormatAccuracyTokensCorrect/Total
csv100.0%5474/4
toon100.0%6444/4
xml100.0%1,6634/4
json-pretty0.0%1,4520/4
yaml0.0%1,1350/4
json-compact0.0%8930/4
Inconsistent field count (missing salary in row 10)
FormatAccuracyTokensCorrect/Total
csv100.0%4704/4
toon100.0%5634/4
json-compact75.0%7673/4
xml100.0%1,4324/4
yaml75.0%9773/4
json-pretty75.0%1,2513/4
Missing required fields (no email in multiple rows)
FormatAccuracyTokensCorrect/Total
csv100.0%4424/4
toon100.0%5354/4
xml100.0%1,3864/4
yaml75.0%9413/4
json-pretty75.0%1,2073/4
json-compact50.0%7322/4
Feature flags keyed by name
FormatAccuracyTokensCorrect/Total
toon97.1%93166/68
json-compact94.1%1,26464/68
yaml92.6%1,44363/68
json-pretty95.6%1,87365/68
xml95.6%2,30665/68
Contacts with nested address and plan groups
FormatAccuracyTokensCorrect/Total
toon94.4%1,44468/72
json-compact91.7%2,35766/72
yaml94.4%2,79768/72
json-pretty97.2%4,01470/72
xml98.6%4,53471/72

Run Configuration

  • Models tested: claude-haiku-4-5-20251001, gemini-3.6-flash, gpt-5.4-nano, grok-4.5
  • Formats compared: TOON, JSON, XML, YAML, JSON compact, CSV
  • Token counting: Using gpt-tokenizer with o200k_base encoding (GPT-5 tokenizer). Other providers tokenize differently, so absolute counts are tokenizer-specific; relative differences between formats hold directionally.
  • Reasoning: Disabled via the AI SDK's universal reasoning: 'none' (Gemini 3 floors at minimal thinking, grok-4.5 at low)
  • Temperature: Not set (models use their defaults)
  • Total evaluations: 244 questions Γ— 6 formats Γ— 4 models = 5,856 LLM calls

What the datasets contain, how the questions are generated, and how answers are validated is documented in the benchmark README.

Token Efficiency

Token counts are measured using the GPT-5 o200k_base tokenizer via gpt-tokenizer. Savings are calculated against formatted JSON (2-space indentation) as the primary baseline, with additional comparisons to compact JSON (minified), YAML, and XML. Actual savings vary by model and tokenizer.

The benchmarks test datasets across different structural patterns (uniform, semi-uniform, nested, deeply nested) to show where TOON excels and where other formats may be better.

Mixed-Structure Track

Datasets with nested or semi-uniform structures. CSV excluded as it cannot properly represent these structures.

πŸ›’ E-commerce orders with nested structures  β”Š  Tabular: 33%
   β”‚
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘    72,832 tokens
   β”œβ”€ vs JSON          (βˆ’32.9%)               108,611 tokens
   β”œβ”€ vs JSON compact  (+5.6%)                 68,944 tokens
   β”œβ”€ vs YAML          (βˆ’14.0%)                84,701 tokens
   └─ vs XML           (βˆ’40.4%)               122,119 tokens

🧾 Semi-uniform event logs  β”Š  Tabular: 50%
   β”‚
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘   154,084 tokens
   β”œβ”€ vs JSON          (βˆ’15.0%)               181,201 tokens
   β”œβ”€ vs JSON compact  (+19.9%)               128,529 tokens
   β”œβ”€ vs YAML          (βˆ’0.8%)                155,397 tokens
   └─ vs XML           (βˆ’25.2%)               205,859 tokens

🧩 Deeply nested configuration  β”Š  Tabular: 0%
   β”‚
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘       589 tokens
   β”œβ”€ vs JSON          (βˆ’34.9%)                   905 tokens
   β”œβ”€ vs JSON compact  (+6.7%)                    552 tokens
   β”œβ”€ vs YAML          (βˆ’11.0%)                   662 tokens
   └─ vs XML           (βˆ’40.9%)                   997 tokens

πŸ“Š Feature flags keyed by name  β”Š  Tabular: 100%
   β”‚
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    10,503 tokens
   β”œβ”€ vs JSON          (βˆ’54.6%)                23,141 tokens
   β”œβ”€ vs JSON compact  (βˆ’32.8%)                15,635 tokens
   β”œβ”€ vs YAML          (βˆ’41.3%)                17,905 tokens
   └─ vs XML           (βˆ’63.3%)                28,655 tokens

πŸ“Š Contacts with nested address and plan groups  β”Š  Tabular: 100%
   β”‚
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘    26,726 tokens
   β”œβ”€ vs JSON          (βˆ’66.5%)                79,779 tokens
   β”œβ”€ vs JSON compact  (βˆ’42.9%)                46,791 tokens
   β”œβ”€ vs YAML          (βˆ’51.8%)                55,475 tokens
   └─ vs XML           (βˆ’70.4%)                90,306 tokens

──────────────────────────────────── Total ────────────────────────────────────
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘   264,734 tokens
   β”œβ”€ vs JSON          (βˆ’32.7%)               393,637 tokens
   β”œβ”€ vs JSON compact  (+1.6%)                260,451 tokens
   β”œβ”€ vs YAML          (βˆ’15.7%)               314,140 tokens
   └─ vs XML           (βˆ’40.9%)               447,936 tokens

Flat-Only Track

Datasets with flat, fully tabular-eligible data where CSV is applicable.

πŸ‘₯ Uniform employee records  β”Š  Tabular: 100%
   β”‚
   CSV                 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    47,153 tokens
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ    49,978 tokens   (+6.0% vs CSV)
   β”œβ”€ vs JSON          (βˆ’60.7%)               127,061 tokens
   β”œβ”€ vs JSON compact  (βˆ’36.8%)                79,057 tokens
   β”œβ”€ vs YAML          (βˆ’50.0%)               100,054 tokens
   └─ vs XML           (βˆ’65.9%)               146,605 tokens

πŸ“ˆ Time-series analytics data  β”Š  Tabular: 100%
   β”‚
   CSV                 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘     8,383 tokens
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     9,115 tokens   (+8.7% vs CSV)
   β”œβ”€ vs JSON          (βˆ’59.0%)                22,245 tokens
   β”œβ”€ vs JSON compact  (βˆ’35.9%)                14,211 tokens
   β”œβ”€ vs YAML          (βˆ’49.0%)                17,858 tokens
   └─ vs XML           (βˆ’65.8%)                26,616 tokens

⭐ Top 100 GitHub repositories  β”Š  Tabular: 100%
   β”‚
   CSV                 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘     8,711 tokens
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ     8,937 tokens   (+2.6% vs CSV)
   β”œβ”€ vs JSON          (βˆ’41.7%)                15,337 tokens
   β”œβ”€ vs JSON compact  (βˆ’23.2%)                11,640 tokens
   β”œβ”€ vs YAML          (βˆ’33.0%)                13,337 tokens
   └─ vs XML           (βˆ’48.3%)                17,294 tokens

──────────────────────────────────── Total ────────────────────────────────────
   CSV                 β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘    64,247 tokens
   TOON                β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ    68,030 tokens   (+5.9% vs CSV)
   β”œβ”€ vs JSON          (βˆ’58.7%)               164,643 tokens
   β”œβ”€ vs JSON compact  (βˆ’35.2%)               104,908 tokens
   β”œβ”€ vs YAML          (βˆ’48.2%)               131,249 tokens
   └─ vs XML           (βˆ’64.3%)               190,515 tokens

Token counts use gpt-tokenizer with o200k_base encoding (GPT-5 tokenizer). Other providers tokenize differently, so absolute counts are tokenizer-specific; relative differences between formats hold directionally.

Show detailed examples

πŸ“ˆ Time-series analytics data

Savings: 13,130 tokens (59.0% reduction vs JSON)

JSON (22,245 tokens):

{
  "metrics": [
    {
      "date": "2025-01-01",
      "views": 6138,
      "clicks": 174,
      "conversions": 12,
      "revenue": 2712.49,
      "bounceRate": 0.35
    },
    {
      "date": "2025-01-02",
      "views": 4616,
      "clicks": 274,
      "conversions": 34,
      "revenue": 9156.29,
      "bounceRate": 0.56
    },
    {
      "date": "2025-01-03",
      "views": 4460,
      "clicks": 143,
      "conversions": 8,
      "revenue": 1317.98,
      "bounceRate": 0.59
    },
    {
      "date": "2025-01-04",
      "views": 4740,
      "clicks": 125,
      "conversions": 13,
      "revenue": 2934.77,
      "bounceRate": 0.37
    },
    {
      "date": "2025-01-05",
      "views": 6428,
      "clicks": 369,
      "conversions": 19,
      "revenue": 1317.24,
      "bounceRate": 0.3
    }
  ]
}

TOON (9,115 tokens):

metrics[5]{date,views,clicks,conversions,revenue,bounceRate}:
  2025-01-01,6138,174,12,2712.49,0.35
  2025-01-02,4616,274,34,9156.29,0.56
  2025-01-03,4460,143,8,1317.98,0.59
  2025-01-04,4740,125,13,2934.77,0.37
  2025-01-05,6428,369,19,1317.24,0.3

⭐ Top 100 GitHub repositories

Savings: 6,400 tokens (41.7% reduction vs JSON)

JSON (15,337 tokens):

{
  "repositories": [
    {
      "id": 132750724,
      "name": "build-your-own-x",
      "repo": "codecrafters-io/build-your-own-x",
      "description": "Master programming by recreating your favorite technologies from scratch.",
      "createdAt": "2018-05-09T12:03:18Z",
      "updatedAt": "2026-07-23T18:57:15Z",
      "pushedAt": "2026-07-14T19:25:58Z",
      "stars": 530712,
      "watchers": 6778,
      "forks": 50205,
      "defaultBranch": "master"
    },
    {
      "id": 21737465,
      "name": "awesome",
      "repo": "sindresorhus/awesome",
      "description": "😎 Awesome lists about all kinds of interesting topics",
      "createdAt": "2014-07-11T13:42:37Z",
      "updatedAt": "2026-07-23T18:57:24Z",
      "pushedAt": "2026-06-30T18:21:16Z",
      "stars": 488074,
      "watchers": 8292,
      "forks": 36010,
      "defaultBranch": "main"
    },
    {
      "id": 28457823,
      "name": "freeCodeCamp",
      "repo": "freeCodeCamp/freeCodeCamp",
      "description": "freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming,…",
      "createdAt": "2014-12-24T17:49:19Z",
      "updatedAt": "2026-07-22T07:01:33Z",
      "pushedAt": "2026-07-21T18:00:51Z",
      "stars": 452380,
      "watchers": 8590,
      "forks": 45624,
      "defaultBranch": "main"
    }
  ]
}

TOON (8,937 tokens):

repositories[3]{id,name,repo,description,createdAt,updatedAt,pushedAt,stars,watchers,forks,defaultBranch}:
  132750724,build-your-own-x,codecrafters-io/build-your-own-x,Master programming by recreating your favorite technologies from scratch.,"2018-05-09T12:03:18Z","2026-07-23T18:57:15Z","2026-07-14T19:25:58Z",530712,6778,50205,master
  21737465,awesome,sindresorhus/awesome,😎 Awesome lists about all kinds of interesting topics,"2014-07-11T13:42:37Z","2026-07-23T18:57:24Z","2026-06-30T18:21:16Z",488074,8292,36010,main
  28457823,freeCodeCamp,freeCodeCamp/freeCodeCamp,"freeCodeCamp.org's open-source codebase and curriculum. Learn math, programming,…","2014-12-24T17:49:19Z","2026-07-22T07:01:33Z","2026-07-21T18:00:51Z",452380,8590,45624,main

Installation & Quick Start

# npm
npm install @toon-format/toon

# pnpm
pnpm add @toon-format/toon

# yarn
yarn add @toon-format/toon

To keep the CLI around instead of invoking it through npx, install it globally:

npm install -g @toon-format/cli

Example usage:

import { encode } from '@toon-format/toon'

const data = {
  users: [
    { id: 1, name: 'Ada', role: 'admin' },
    { id: 2, name: 'Bob', role: 'user' }
  ]
}

console.log(encode(data))
// users[2]{id,name,role}:
//   1,Ada,admin
//   2,Bob,user

Streaming large datasets:

import { encodeLines } from '@toon-format/toon'

const largeData = await fetchThousandsOfRecords()

// Memory-efficient streaming for large data
for (const line of encodeLines(largeData)) {
  process.stdout.write(`${line}\n`)
}

[!TIP] For streaming decode APIs, see decodeFromLines() and decodeStream().

Transforming values with replacer:

import { encode } from '@toon-format/toon'

// Remove sensitive fields
const user = { name: 'Ada', password: 'secret', email: 'ada@example.com' }
const safe = encode(user, {
  replacer: (key, value) => key === 'password' ? undefined : value
})
// name: Ada
// email: ada@example.com

[!TIP] The replacer function provides fine-grained control over encoding, similar to JSON.stringify's replacer but with path tracking. See the API Reference for more examples, including verbatim output with rawString.

CLI

Command-line tool for quick JSON↔TOON conversions, token analysis, and pipeline integration. Auto-detects format from file extension, supports stdin/stdout workflows, and offers delimiter options (comma, tab, pipe) that trade readability for fewer tokens.

# Encode JSON to TOON (auto-detected)
npx @toon-format/cli input.json -o output.toon

# Decode TOON to JSON (auto-detected)
npx @toon-format/cli data.toon -o output.json

# Pipe from stdin (no argument needed)
cat data.json | npx @toon-format/cli
echo '{"name": "Ada"}' | npx @toon-format/cli

# Output to stdout
npx @toon-format/cli input.json

# Show token savings
npx @toon-format/cli data.json --stats

[!TIP] See the full CLI documentation for all options, examples, and advanced usage.

Using TOON with LLMs

TOON works best when you show the format instead of describing it. Once a model sees one tabular example, the header – [N] length plus {fields} field list – tells it how to read the rest. Wrap data in ```toon code blocks for input, and show the expected header template when asking models to generate TOON. Tab delimiters buy further token savings. Full-line # comments are stripped on decode, so hand-annotated prompt data – and model output with explainer lines – still decodes cleanly.

Follow the detailed LLM integration guide for strategies, examples, and validation techniques.

Ecosystem

Playgrounds – the official playground converts JSON or YAML to TOON in real time, compares token counts, and shares experiments by URL. Community alternatives: Format Tokenization Playground, TOON Tools.

Editors – TOON Language Support for VS Code (code --install-extension vishalraut.vscode-toon) adds highlighting, validation, and token analysis. tree-sitter-toon covers Neovim, Helix, Emacs, and Zed; toon.nvim is a Lua-native alternative. Elsewhere, YAML highlighting is a close approximation.

Tooling – Tooner is an MCP proxy that converts JSON tool responses to TOON.

Documentation

Getting Started

  • Introduction & Installation – What TOON is, when to use it, first steps
  • Format Overview – Complete syntax with examples
  • Benchmarks – Accuracy & token efficiency results

Tools & Integration

  • CLI – Command-line tool for JSON↔TOON conversions
  • Playgrounds – Interactive tools
  • Using TOON with LLMs – Prompting strategies & validation

References

  • API Reference – TypeScript/JavaScript encode/decode API
  • Syntax Cheatsheet – Quick format lookup
  • Specification – Normative rules for implementers
  • Glossary – One name per concept, for contributors and tooling

Media Type & File Extension

TOON files use the .toon extension and the provisional media type text/toon. Documents are always UTF-8; the charset=utf-8 parameter may be given but is assumed when absent. See SPEC.md Β§17 for normative details.

Other Implementations

TOON has official and community implementations across multiple languages including Python, Rust, Go, Java, Swift, .NET, and many more.

See the full list of implementations in the documentation.

Credits

  • Logo design by ιˆ΄ζœ¨γƒƒγ‚―γ‚Ή(SZKX)

License

MIT License Β© 2025-PRESENT Johann Schopplich

Releases

Release information has not been added yet.

Complete your AI stack

Move from research to writing, visual communication, presentations, and automation.

Perplexity logo
Perplexity
Find information

AI-powered search and research assistant

View tool
Claude logo
Claude
Analyze findings

Long-context AI assistant focused on reasoning and documents

View tool
Midjourney logo
Midjourney
Create visuals

AI image and video generation with advanced personalization

View tool
AIWriteBook logo
AIWriteBook
Long-form content

End-to-end AI platform for writing and publishing books.

View tool
n8n logo
n8n
Automate research

Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.

View tool
Best alternatives

Compare similar tools in the same category.

CodeRabbit logo

CodeRabbit

AI-powered code review assistant for pull requests.

OpenClaw logo

OpenClaw

Your own personal AI assistant. Any OS. Any Platform. The lobster way. 🦞

Cursor logo

Cursor

AI coding editor and autonomous software development platform

DeepSeek logo

DeepSeek

AI assistant for reasoning, coding, research, and agent tasks

ECC logo

ECC

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

View all in this category
Help
Pick an answer below
Hi! I can point you to the right tool or guide. What are you looking for?
Browse all articles