TOON Examples

July 26, 2026 · View on GitHub

Example TOON files, one per format feature – each filename names the feature it demonstrates. All files validate against the reference implementation: valid examples decode in strict mode, invalid examples error, and every conversion pair is generated by the reference encoder and round-trip verified.

Valid Examples

Objects

  • valid/objects.toon – Flat object with primitive values

    • Key-value pairs across all data types: string, number, boolean, null
    • Spec: §8
  • valid/nested-objects.toon – Multi-level nested objects

    • Indentation-based nesting (2 spaces per level) instead of braces
    • Spec: §8, §12

Arrays

  • valid/primitive-arrays.toon – Inline primitive arrays

    • Compact inline form [N]: item1,item2,item3 and the empty array []
    • Spec: §9.1
  • valid/mixed-arrays.toon – Mixed-type array (list form)

    • One - item per element, used wherever neither inline nor tabular form applies
    • Spec: §9.4

Comments

  • valid/comments.toon – Full-line # comments
    • Stripped by decoders in a lexical pre-pass, before row counting – decode-only; encoders never emit them
    • Spec: §5.1

Delimiters

  • valid/pipe-delimiter.toon – Pipe delimiter (|)

    • Delimiter marker appears in both header [N|] and field list {field|...}
    • Spec: §11
  • valid/tab-delimiter.toon – Tab delimiter (\t)

    • Tab character appears in both header and between fields
    • Spec: §11
  • valid/delimiter-scoping.toon – Document vs active delimiter

    • Tabular row cells split only on the active delimiter; object field values follow document delimiter quoting
    • Spec: §11

Conversions

Side-by-side JSON ↔ TOON pairs, one per tabular form:

Invalid Examples

Files that intentionally violate TOON syntax rules and MUST error in strict mode:

For reference test fixtures, see the tests/ directory.