Skip to content

What is TOON?

TOON stands for Token-Oriented Object Notation. It is a text format for the same kinds of data you can store in JSON. It can write a list of similar records as a small table, which can make structured data shorter to include in an AI prompt.

How does TOON work?

JSON repeats field names in every object. When a list contains objects with the same fields and simple values, TOON can put the field names on one line and write the values below. Indentation shows which values belong together.

TOON can still describe nested objects and lists. A list whose items have different fields usually needs a longer form. Strings can also need quotes, for example when a name contains the same comma used to separate columns.

The same contacts in JSON and TOON

In the TOON header, [2] says there are two rows. The braces give the column names in order. The first value in each row is the ID. The second is the name.

JSON
[
  {"id": 42, "name": "Avery"},
  {"id": 51, "name": "Ellis"}
]
TOON
[2]{id,name}:
  42,Avery
  51,Ellis

When is TOON useful?

Try it when an AI prompt includes many similar records, such as search results, a list of products or a report. A model reads text in small chunks called tokens. Repeating fewer field names can reduce the number of input tokens.

Savings vary with the data and the model. Compare token counts with the tokenizer for the model you use. Also test whether the model still reads the fields and produces the right answer. A shorter prompt only helps if it still does the job.

Keep JSON when the system you send data to expects JSON, such as a web API. TOON is useful as a prompt representation. You can keep the original JSON as the source for your app.

How do I convert it?

In JSON to TOON, load the example or paste your own JSON and select Convert to TOON. Check the header and column order before copying the text into a prompt.

In TOON to JSON, paste the TOON example or open the .toon file and select Convert to JSON. Check that the decoded records match what you sent. If you copied the text out of a chat, leave out any Markdown fences around the example.

Does TOON change the data?

The contact names and IDs stay the same. Only the way they are written changes. To check a new prompt, convert your JSON to TOON, then turn that result back into JSON. Compare the values in the two JSON files. The spaces and line breaks may look different.

A model can make a mistake when it writes TOON. If the model changes a name or leaves out a row, a format converter cannot recover the original value. Keep a copy of the source data when the result needs to match it.

Why did the converter reject my TOON?

Start with the row count. If you add a contact, change [2] to [3] and add a row with one value for each column. Keep the rows at the same indent and quote any value that contains the delimiter.

Check long IDs before converting. If the ID is a label and you never do maths with it, store it as text in the source JSON. Quoting it preserves leading zeros and keeps large IDs from losing digits in tools that use ordinary JavaScript numbers.

Format reference