Skip to the content
GigaJSON
All tools
Format and check
View and query
Convert
Encode and decode
Sample files
Guides Open GigaJSON

JSON vs TOON: token counts measured on six kinds of data

· 4 min read · By GigaJSON

TOON (Token-Oriented Object Notation) is a text format for putting JSON data into AI prompts with fewer tokens. For a list of similar records it writes the field names once, in a header, followed by one row per record. That can save a lot. It can also cost more, and which one you get depends on a single detail of your data.

We measured it on six kinds of records and found that detail: whether any field holds a list.

How we measured

Each data set is the first 100 records of one kind from the Sample JSON Files generator (the same choices always give the same file, so you can rebuild them). The records are made up, but shaped like API data: users, customers, products, log events, orders and blog posts, with nested objects, dates, nulls and lists.

Each set was counted four ways with the o200k_base tokenizer: as JSON with 2-space indentation, as compact JSON, as TOON, and as CSV. The counts come from the same code the JSON Token Counter runs, and the TOON output was decoded again to check that it held exactly the same values. To check a row yourself, generate the same file, keep the first 100 records and paste them into the token counter.

The results

Data (100 records) Indented JSON Compact JSON TOON TOON vs compact CSV
Users 15,552 10,364 6,499 37% fewer 6,241
Log events 11,942 7,873 5,375 32% fewer 5,134
Customers 15,734 10,640 12,515 18% more 7,033
Products 15,232 9,522 11,895 25% more 5,804
Orders 29,992 18,578 19,354 4% more 16,346
Blog posts 26,116 19,476 20,624 6% more 19,114

Two things stand out. Removing the indentation saved 25 to 38% everywhere, with no change to the data. And TOON won clearly on two sets and lost on the other four.

Why: one list field changes the format

Users and log events have nested objects (a user's profile, an event's request) but no lists. TOON folds the nested fields into the header and writes each record as one row:

[100]{id,username,email,role,active,created_at,last_login,profile{first_name,last_name,age,country},settings{theme,locale,notifications}}:
  1,olivia1,olivia.nguyen1@example.com,member,true,"2025-06-23T01:26:50.724Z","2025-06-10T04:13:38.833Z",Olivia,Nguyen,48,DE,light,ja-JP,false

Customers and products have a tags list. A list can't go into a row, so TOON falls back to its list form, which writes every field name again for every record:

[100]:
  - id: cus_000001
    name: Noah Orozco
    email: noah.orozco1@example.com

That's close to YAML, and for these records it's larger than compact JSON, which at least has no indentation.

To check that the list was the cause, we removed the list fields and counted again:

Data (100 records), without list fields Compact JSON TOON TOON vs compact
Customers, without tags 10,007 6,454 36% fewer
Products, without tags 8,875 5,121 42% fewer

With tags gone, both sets switch to the table form and TOON wins by the same margin as for users and events. Orders and posts have larger lists (an order's items, a post's comments), and those carry much of the data, so dropping them isn't a fair comparison there.

What about CSV?

CSV was the smallest in every case, a little below TOON on the data TOON handles well. It's also the most lossy: every value becomes text, so a model can't tell the number 7 from the string "7" or null from an empty string, and nested lists end up as JSON inside a cell. TOON keeps the types and the structure, which is why it decodes back to the same JSON.

What to do with your data

  1. Minify first. Compact JSON is a quarter to a third smaller than indented JSON, and every tool accepts it.
  2. Check for list fields. If your records have none, TOON is likely to save another third. If they do, compact JSON is probably smaller.
  3. Drop what the question doesn't need. Leaving out a tags field you don't need turned TOON from the bigger format into the smaller one here. The JSON Token Counter lets you pick fields and rows and shows the count for both formats as you go.
  4. Measure, don't assume. Paste your own data into JSON to TOON to see both counts. Fewer tokens don't guarantee better answers, and a tool or API that expects JSON still needs JSON.

For a walkthrough of preparing a real API response for a prompt, see how to reduce JSON tokens for AI prompts.

Questions

Does TOON use fewer tokens than JSON?

Only for some data. In our measurements TOON used 32 to 42% fewer tokens than compact JSON for lists of records whose values fit one row each, and 4 to 25% more when every record had a list field such as tags.

Why does a list field make TOON bigger?

TOON's table form needs each record to fit one row. Nested objects can be folded into columns, but a list inside a record can't, so TOON switches to its list form, which repeats every field name in every record, like YAML.

Is minifying JSON enough?

It's the first step. Removing indentation alone cut 25 to 38% of the tokens in every data set we measured, and it changes nothing about the data.

Which tokenizer were the counts made with?

o200k_base, through gpt-tokenizer 4.0.0, with @toon-format/toon 4.4.0 for the conversion. Other tokenizers give different numbers, so measure your own data with the tokenizer your workflow uses.

More from the blog