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

TOON to JSON

TOON spec 4.4 · strict and non-strict decoding · line-numbered errors

Paste TOON — out of a model's reply, a prompt template or a .toon file — and get JSON back. Strict mode, the default, checks what the spec requires a decoder to check: that every declared [N] matches the rows or values under it, that each row is as wide as its header, and that indentation is consistent. The reverse is JSON → TOON.

Paste TOON to start.

How to convert TOON to JSON

  1. Paste TOON, or drop a .toon file on the left pane. If it is wrapped in a Markdown ``` fence, as models usually write it, the fence is removed for you.
  2. Leave strict mode on to catch broken tables: a header that says [3] above two rows is an error, reported with its line number.
  3. Untick strict mode to decode a file that is wrong in one of the ways the spec lets a decoder forgive — counts that do not add up, a duplicated key, tab indentation, a blank line inside a table.
  4. If the file indents four spaces per level, set TOON indent to match.
  5. Copy the JSON, or download it.

Reading TOON a model wrote

Models produce TOON that looks right and is not: a table header promising [5] rows over four, a row with one cell too many because a value contained the delimiter and was not quoted, a field indented three spaces instead of two. Strict mode exists to catch exactly these, because a JSON reader silently accepting a four-row table where five were declared is how missing data goes unnoticed. The error message carries the line number and what was expected, so you can fix the line or ask the model to.

Non-strict mode is not a general “try harder”. Spec 4.4 allows exactly five recoveries — mismatched counts, duplicate keys (last one wins), tab or uneven indentation, blank lines inside a table or list, and an indentation jump on the first line of a block — and every other defect, including a row of the wrong width or a malformed header, is still an error.

How values are read

An unquoted token is a number only if it matches JSON's number grammar exactly, so 05, +5, 1_000 and NaN come back as strings, and a quoted "42" stays the string "42". true, false and null are literals; everything else is a string. Lines whose first non-space character is # are comments and are dropped, and key: [] is an empty array.

A dotted key such as server.port: 8080 is one literal key, not a path: spec 4.0 removed the option that expanded those into nested objects. Integers beyond 253 are read as JavaScript numbers and can lose their last digits; the status line points at the first one if any are present.

FAQ

Why does tags[2]: a,b,c fail?

The header declares two values and three follow. In strict mode a count mismatch is an error; in non-strict mode the decoder keeps all three and ignores the declared length.

Why are the keys in a different order than in my original JSON?

Rows of a table decode with their keys in the header's field order, which is the first element's key order. Objects with the same keys in a different order are equal in JSON, and the spec defines equality the same way.

My file uses [#3] headers and will not decode.

The # length marker was removed in spec 2.0 and current decoders reject it. Delete the # inside the brackets — items[#3] becomes items[3] — and the rest of the file is unaffected.

Is a key called __proto__ safe?

Yes. The spec requires decoders to create every key, including __proto__, constructor and prototype, as an ordinary key without touching the object's prototype, and the reference decoder used here does.

Is my TOON uploaded?

No. The decoder is the reference library @toon-format/toon 4.4.0, downloaded to your browser on first use; decoding happens in this tab.