JSON to TOON

Input
Output

JSON to TOON Converter

TOON writes the same data as JSON with fewer tokens: indentation instead of braces, and a list of records as one header with a row per item. Paste JSON to get TOON for a prompt, or switch direction to read TOON back as JSON.

Example: three orders, ready for a prompt

An API response with three orders. TOON writes the keys once, in the header, and each order as one row:

JSON

{
  "orders": [
    {
      "id": "ORD-20419",
      "customer": "Ana Souza",
      "city": "Pune",
      "total": 740.5,
      "status": "paid"
    },
    {
      "id": "ORD-20420",
      "customer": "Ravi Kumar",
      "city": "Delhi",
      "total": 120,
      "status": "pending"
    },
    {
      "id": "ORD-20421",
      "customer": "Mei Lin",
      "city": "Mumbai",
      "total": 2299,
      "status": "paid"
    }
  ]
}

Output

orders[3]{id,customer,city,total,status}:
  ORD-20419,Ana Souza,Pune,740.5,paid
  ORD-20420,Ravi Kumar,Delhi,120,pending
  ORD-20421,Mei Lin,Mumbai,2299,paid

How do I use the JSON to TOON?

  1. Paste JSON, or open a .json file.
  2. Pick the delimiter (comma, tab or pipe) and the indent.
  3. Copy the TOON into your prompt, or save it as a .toon file.

What does the JSON to TOON do?

  • The official TOON library, spec v4.4
  • Lists of records as one header and rows
  • Exact big numbers kept

When to use the JSON to TOON

Language models read JSON well but pay for every brace, quote and repeated key. TOON keeps the same data model (objects, arrays, strings, numbers, true, false and null) and drops most of that punctuation: nested objects are indented like YAML, and an array of objects that share the same keys becomes one header line, items[3]{sku,name,qty}:, with one row per item. The [3] tells a model how many rows to expect.

On a list of records TOON takes noticeably fewer tokens than minified JSON (about a quarter fewer on the orders in the example) and far fewer than indented JSON. A flat list is smaller still as CSV, but CSV can't hold the rest of the document; TOON keeps nesting, so a whole API response converts. Strings are quoted only when they need to be, for example when they contain the delimiter or look like a number.

Bracely uses the official TOON library, so the output follows the spec exactly and any TOON reader can read it back. Very long numbers, like 64-bit ids, are written exactly as they are in the JSON.

Frequently asked questions

Can I convert YAML to TOON?
Yes. Choose YAML → TOON to convert a YAML file, or TOON → YAML to read TOON back as YAML; both use the same converter.
Which delimiter should I use?
Comma is the default and reads most naturally. Tab sometimes saves a token or two, and pipe is clear when the values contain commas, since they then don't need quotes.
Will a model understand TOON?
It looks like YAML with a table, which models are used to. To be safe, say in the prompt that the data is TOON and that [N] is the number of rows.
How many tokens does it save?
It depends on the data: on three orders, 83 tokens of minified JSON became 61 of TOON (GPT-4o's tokenizer). Token counter compares JSON, YAML, CSV and TOON for your own data.
Is my data uploaded?
No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.

More JSON tools

Bracely has 108 JSON tools in one page. Related ones:

Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.2 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram