jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Sign in Create free accountSign up

JSON to TOON

TOON spec 4.4 · reference encoder @toon-format/toon 4.4.0 · comma, tab or pipe

TOON — Token-Oriented Object Notation — carries the same data as JSON with less punctuation. Objects are indented instead of braced, strings are quoted only when they must be, and an array of same-shaped objects becomes a table whose field names are written once. Paste JSON to get TOON for a prompt, measured against the JSON it replaces. The reverse is TOON → JSON.

Paste JSON to start.

How to convert JSON to TOON

  1. Paste JSON, or drop a .json file on the left pane. The TOON appears as you type.
  2. Pick a delimiter. Comma is the default; tab or pipe pay off when your values are full of commas, because every string that contains the active delimiter has to be quoted.
  3. Read the table under the panes: the TOON against the same data as minified JSON and as 2-space JSON, in characters and UTF-8 bytes.
  4. Copy the TOON into your prompt, or download it as a .toon file.

What the encoder does with your data

The form of each value follows from its shape — the spec forbids an encoder from choosing by preference — so the same JSON always gives the same TOON. An array whose elements are all objects with the same keys and primitive values becomes a table: the length and the field list once, then one row per element.

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

Since spec 4.0 two more shapes collapse the same way. An object whose values are same-shaped objects becomes a keyed table, marked by the colon inside the brackets: users[2:]{age,city}: followed by rows such as alice: 30,Berlin. And a column whose values are themselves same-shaped objects becomes a nested field group in the header — orders[2]{id,customer{name,country},total}: — while each row stays one flat line.

Arrays of primitives go inline (tags[3]: admin,ops,dev), an empty array is tags: [], and anything mixed or irregular falls back to a list of - items. A string is quoted only when leaving it bare would change its meaning: when it is empty, has leading or trailing spaces, looks like a number or true / false / null, contains a colon, quote, backslash, bracket, brace, control character or the active delimiter, or starts with - or #.

When TOON is not smaller

The saving comes from writing repeated keys once, so it depends entirely on how much of your document is uniform arrays. The specification says so itself: TOON is not meant to replace JSON for non-uniform or deeply nested structures, where “JSON may be more efficient”, and for flat tables with no nesting CSV is usually more compact still. A config file of nested objects can come out the same size or larger. That is why the table above measures your actual document rather than quoting a typical figure.

The table counts characters and bytes, not tokens, and deliberately shows no token estimate. Tokenizers differ by model and merge punctuation in ways a character-based guess gets wrong — on nested data, by enough to make a real increase look like a draw. For the number that matters, run both versions through your model provider's own token counter.

Numbers, ids and the round trip

After encoding, the page decodes the TOON again with the same library and checks that it gives back your JSON; the status line says so, or warns if it ever does not. Inside tables the key order follows the header, which the spec allows, so that comparison ignores key order.

Integers beyond 253 — 64-bit database ids, snowflake-style ids — are the one place JSON tools in a browser usually lose data, because JSON.parse rounds them. This page reads the digits from your text and writes them into the TOON unchanged. A JavaScript decoder reading that TOON will still round them, so the status line counts them for you.

FAQ

What is the number in brackets for?

Every array header declares its length — [2], or [2:] for a keyed table. A strict decoder errors when the rows or values that follow do not add up, which is how a truncated or padded table gets noticed instead of silently accepted. The length is mandatory; the spec lists making it optional as out of scope.

Where did the [#3] length marker and key folding go?

Both were removed from the spec. The [#N] marker went in version 2.0 and decoders now reject it; the keyFolding option that wrote a.b.c: 1 for nested single-key objects went in 4.0, and a dotted key is now always a literal key. Encoders following spec 4.4, including this one, write neither.

Can TOON have comments?

Decoders drop any line whose first non-space character is # (since spec 4.0), so you can annotate a TOON file by hand. Encoders never write comments, and a string value that starts with # is always quoted so it cannot be mistaken for one.

Which version of TOON does this produce?

Spec 4.4, dated 8 October 2026 (a Working Draft, MIT-licensed, at github.com/toon-format/spec). The encoder is the reference implementation, @toon-format/toon 4.4.0, maintained by the spec's author and loaded from jsDelivr the first time you use the page. We run the spec repository's conformance fixtures — 564 encode and decode cases — against that exact file, and all of them pass.

Is my JSON sent anywhere?

No. The library is downloaded to your browser like any other script, and the conversion runs in this tab. Nothing you paste is uploaded, and after the first load the page keeps working offline.

What file extension and media type does TOON use?

.toon, and the provisional media type text/toon, always UTF-8. Output uses LF line endings with no trailing newline, as the spec requires of encoders.