June 12, 2026 · 2 min read · Yunus Emre Vurgun
TOON Format Grammar: A Practical Overview
TOON (Token-Oriented Object Notation) is a line-based text format for JSON-shaped data. It trades braces and repeated keys for indentation and tables. This overview covers the parts you meet in practice; the normative rules live in the specification, and the YJTOON encoder is checked against the reference implementation on every build.
Objects and indentation
An object is a list of key: value lines. Nesting is two spaces of indentation; there are no braces and no trailing commas. A key with nothing after the colon introduces a nested object.
dataset: slug: tcp-ip-protocol-suite title: TCP/IP Protocol Suite
Four array forms
The array length is written in the header, in square brackets. The encoder picks the form from the data's shape:
| Form | When | Example |
|---|---|---|
| Inline | Array of primitives | tags[3]: a,b,c |
| Tabular | Array of objects with the same keys and primitive values | rows[2]{id,name}: then 1,Ada and 2,Linus |
| Keyed tabular | Object whose values are uniform objects | env[2:]{region,replicas}: |
| List | Anything else: mixed types, non-uniform objects | items[2]: then - a: 1 lines |
The tabular form is where the savings come from: field names are written once in the header instead of once per record. A real example from this site:
data[4]{layer,protocols}:
Application,"HTTP, HTTPS, FTP, SMTP, DNS, SSH"
Transport,"TCP, UDP"
Internet,"IP, ICMP, ARP, IGMP"
Network Access,"Ethernet, Wi-Fi, PPP"Strings and quoting
Strings are unquoted unless that would be ambiguous. Spaces inside a string are fine (Network Access above). A string is quoted when it is empty, has leading or trailing spaces, equals true, false or null, looks like a number, contains a comma, colon, quote, backslash, bracket or brace, starts with a hyphen or #, or contains a control character. Quoted strings use the escapes \\, \", \n, \r and \t.
Numbers, booleans, null
Numbers are written in canonical decimal form: no exponent for ordinary values, no trailing zeros (1.50 becomes 1.5), and -0 becomes 0. NaN and infinities become null. Booleans and null are the bare words.
Empty values
An empty array is key: []. An empty object is a bare key: line. Documents have no trailing newline.
Reading it back
Because every array declares its length, a parser never has to guess where a block ends, which is why a working reader fits in under a hundred lines — see a small TOON parser in Python. To see the encoder work on your own data, paste JSON into TOON Studio.