Skip to main content

TOON to JSON Converter

Convert TOON back to standard JSON for storage or tooling that expects JSON.

Import File

Maximum file size: 5.00 MB | Accepted format: .toon, .txt

Recovering JSON from TOON means putting back the two things the format removed: most quotes and the field boundaries. Quoted values keep their string type, bare values have their type inferred, and the header's row and column counts are checked against the data.

How types are recovered

A value written in quotes is always a string, whatever it contains: "7" is the string 7 and "true" is the string true. A bare value is inferred. The tokens true, false and null become JSON literals, a plain decimal such as 42, -1.5 or 1e3 becomes a number, and everything else stays a string.

The rule is deliberately narrow, so you can name its edge cases before you hit them. A bare 02134 stays the string 02134, because numbers with a leading zero are not converted. Hexadecimal such as 0x1A, and the words Infinity and NaN, also stay strings. Numbers beyond 2^53 − 1 lose precision, exactly as they do in JSON.parse: a twenty-digit identifier written bare becomes 12345678901234567000. Hand-written TOON should quote any value whose text matters.

TOON produced by our JSON to TOON converter already quotes strings that would be misread, so converting it back restores the original types.

Header counts are checked

A header such as [3]{id|name|role|active}| declares how many rows follow and what the fields are called, and the converter holds the data to it. A header announcing five rows above two rows of data fails with an error such as Expected 5 rows but found 2. A row with a different number of values than the header has fields fails with the line number and the counts, and extra rows beyond the declared count are rejected too.

That matters most for TOON that came out of a language model, where a table cut off at the output limit is the typical damage: the header is the evidence, and a mismatch now stops the conversion instead of producing a shorter array.

The check cannot tell whether the values themselves are right. A row whose values were reordered against the header, or a hallucinated value, still counts correctly. Validate model output against a schema after converting, as you would any other model output.

The delimiter comes from the header

The header declares the delimiter in its last character: | means pipe-separated rows, while , or : means comma-separated rows. Every row of that table is split with that one delimiter, so there is no per-line guessing and a stray pipe in a comma table is just text.

A value that contains the delimiter is written in quotes and read back intact: 1,"a,b" under a two-column comma header is the two values 1 and a,b. An unquoted delimiter inside a value is a real extra field, and the converter reports the row as having too many values.

Keys and nesting

Plain keys (letters, digits, underscores, dots and hyphens, starting with a letter or underscore) are written bare. Any other key, such as one with a space or a delimiter in it, must be quoted: "full name"|Alice. Array headers accept both forms, so line-items[1]{a|b}| and "line items"[1]{a|b}| are both read as tables.

Nested objects are read from indentation to any depth: a profile| line followed by an indented block becomes an object, and a keyed table can sit at any level. Arrays that are not tables, and empty arrays and objects, are written as inline JSON (tags|["a","b"]) and read back as JSON. A line that cannot be read, for example a table header with no key inside an object, produces an error with its line number.

Check the shape, because valid JSON can still be wrong

Even with the checks above, a successful conversion only proves the TOON was well-formed. A schema-less validator, a linter and JSON.parse will accept a document that carries a wrong value, a mislabeled column, or a number that should have been a string.

Spot-check one value from each type-sensitive column: identifiers, postcodes, version strings, phone numbers, anything zero-padded. If the original JSON still exists, diff against it. If it does not, expanding the result in the JSON editor is a fast way to read the structure before it travels further.

How careful to be depends on where the TOON came from. TOON your own encoder produced and you are converting straight back is low risk. TOON a language model generated is untrusted input: a hallucinated extra column, values reordered against the header, or a table cut off at a token limit may still convert cleanly, so validate against a real schema afterwards.

ThenCatch is a developer toolkit that runs in your browser. Learn more about ThenCatch.