How the TOON Parser Works

A simple explanation of how JSON ↔ TOON conversion happens in the browser

Overview

The TOON Parser is a lightweight, browser-based tool that converts between JSON and TOON (Token-Oriented Object Notation) instantly. All conversion happens locally in your browser — no data is sent to any server.

What is TOON?

TOON is a compact, human-readable alternative to JSON. It removes unnecessary characters such as braces, commas, and quotes wherever possible while maintaining the same data structure. This makes TOON especially useful in AI / LLM prompts where token usage matters.

{
  "id": 1,
  "name": "Ada",
  "tags": ["foo", "bar"]
}

becomes:

id: 1
name: Ada
tags[2]: foo,bar

How JSON → TOON Conversion Works

  1. JSON is parsed using the browser's native JSON parser.
  2. The data structure is walked recursively.
  3. Keys and values are rewritten using TOON rules:
    • No quotes unless required
    • Objects become newline-based key/value entries
    • Arrays include their length, e.g., tags[3]
    • Values are comma-joined for arrays when possible
  4. A final string is assembled for the TOON output.

How TOON → JSON Conversion Works

  1. The TOON text is split into structured lines.
  2. Each line is analyzed to detect:
    • Key/value pairs
    • Array notations (e.g., items[2])
    • Nested objects (via indentation or grouping)
  3. The parser reconstructs proper JSON arrays and objects.
  4. The final output is formatted JSON with correct syntax.

Privacy & Security

All conversions run fully in your browser using JavaScript. No JSON or TOON data is ever uploaded or stored anywhere.