TOON format spec and syntax
TOON expresses any JSON value using indentation instead of brackets. This reference covers each rule with a short example. Conversion is lossless in both directions — valid JSON maps to TOON and back without changing a single value.
Objects
Keys are written one per line as key: value. Keys are unquoted when they are simple identifiers (letters, digits, underscores, hyphens) and quoted otherwise.
name: Ada
role: engineer
"display name": Ada LovelaceNesting
A nested object goes on the following lines, indented by two spaces:
user:
id: 1
address:
city: London
zip: EC1AArrays of objects
Each element starts with a dash. Fields of the same object align under it. This is where TOON saves the most versus JSON, because the field names are not repeated as punctuation.
items:
- id: 1
name: Pen
- id: 2
name: PencilSimple (scalar) arrays
Short arrays of primitives are written inline in square brackets, space-separated. Longer ones break onto dashed lines.
tags: [red green blue]Strings
A string is left unquoted when it is a simple token. Strings containing spaces or special characters are wrapped in double quotes, and inner quotes are escaped with a backslash.
title: Hello
note: "needs a comma, so it is quoted"Numbers, booleans, and null
These are written bare, exactly as in JSON:
count: 42
ratio: 3.14
active: true
deleted: nullEmpty values
An empty object is {} and an empty array is [].
Round-trip guarantee: the converter turns JSON into TOON and TOON back into JSON. If a payload does not round-trip cleanly, that is a bug worth reporting — the formats are designed to be exactly equivalent.
Convert without reading the spec
You rarely need to write TOON by hand. Paste JSON into the converter and it produces valid TOON for you instantly, in your browser.