JSON to TOON Converter

Convert JSON to TOON and back in your browser โ€” your JSON never leaves your browser, and nothing you paste is uploaded.

Direction

Or drag and drop a file onto this box. The file is read in your browser and never uploaded. Files up to 50 MB.
Options

TOON is a young format and its specification is a working draft (v4.4). This page uses @toon-format/toon 4.4.0. Integers beyond 2^53 are kept digit for digit in both directions; decimals and exponent forms are read as 64-bit floats.

    GPT-4o / GPT-4.1 tokenizer (exact for OpenAI models; other models differ)

    For other models, use the LLM Token Counter.

    Your JSON never leaves your browser. The tokenizer file is loaded from this site only when you press Compare tokens. Send passes decoded JSON to the formatter inside your browser tab only.

    TOON is a young text format meant for putting JSON-shaped data into prompts for language models. This page converts JSON to TOON and TOON back to JSON in your browser, and it can count the tokens of both so you decide with numbers instead of guesses. People use it to see whether a long list of records gets cheaper to send, to read TOON that another tool produced, and to check what a round trip does to their data. Your JSON never leaves your browser. The format is still evolving, which is why this page says plainly where it helps and where it does not.

    What is TOON?

    TOON, short for Token-Oriented Object Notation, is a text format that holds the same data as JSON in a more compact layout. It writes an array of uniform objects as a table, with one header line and one row per record, and it uses indentation instead of braces and most quotes. Its specification is still a working draft.

    The specification is at version 4.4 and is labelled a working draft, so details can change between versions. This page pins version 4.4.0 of the open-source @toon-format/toon library, and the conversion follows what that version does, not a promise about future ones.

    How do I convert JSON to TOON?

    Paste your JSON or upload a file, keep JSON to TOON selected, and the TOON appears as you type. Choose the indent size and the delimiter, then copy the result or download it as a .toon file. Switch to TOON to JSON to go back, and press Compare tokens to see how many tokens each version uses.

    How to use this converter

    • Pick a direction: JSON to TOON encodes, and TOON to JSON decodes. The options below the box change to match.
    • Add your data: paste it, upload a .json, .toon or .txt file up to 50 MB, drop a file on the box, or load one of three samples.
    • Set the options: indent size and delimiter for encoding, and strict reading and the JSON indent for decoding. Only options the library supports are shown.
    • Compare tokens: after a conversion, press the button to count the minified JSON against the TOON with the GPT-4o and GPT-4.1 tokenizer.
    • Copy, Download or Send: copy the result, save it as a .toon or .json file, or send decoded JSON to the JSON Formatter.

    Tidy a payload first with the JSON Formatter or put its keys in order with the JSON Sorter, and use the LLM Token Counter to see counts for other models. If your data is one record per line, the JSON to JSONL converter handles that shape, and the YAML to JSON converter reads another indentation-based format.

    When does TOON use fewer tokens than JSON?

    It tends to help with long arrays of records that share the same keys and hold plain values, because the keys are written once in a header instead of in every record. In the first example below, the TOON used 31.1% fewer tokens than the minified JSON. That figure belongs to that data; measure your own before relying on it.

    The table further down shows the measured counts. TOON saves characters mostly when it can replace repeated keys, braces and quotes with one header and plain rows. The more regular the records, the more it has to work with.

    When does TOON not help?

    Nested objects, records with different keys, and arrays of arrays often come out the same size or larger. In the examples below, TOON used 11 more tokens than minified JSON for the nested object and 17 more for the mixed array, because indentation and per-item markers cost tokens that braces do not.

    The deeply nested object and the four records with different keys at the end of the table show the same thing at small scale. TOON does not claim a fixed saving, and neither does this page. Whether a smaller prompt also helps a given model answer better is a separate question that this tool does not test.

    What do real examples look like?

    Each row was converted with this page's own conversion code, and both texts were counted with the o200k_base tokenizer that GPT-4o and GPT-4.1 use. The JSON is counted minified, and the first example is shown in full below the table.

    Minified JSON against TOON, counted with o200k_base
    ExampleJSON charsTOON charsJSON tokensTOON tokensDifference
    Uniform array: 5 user records (sample 1)37920412284โˆ’38 (31.1% fewer)
    Nested object: a service config (sample 2)1851855061+11 (22.0% more)
    Mixed array: different shapes (sample 3)1321504461+17 (38.6% more)
    Deeply nested object37491719+2 (11.8% more)
    Four records with different keys33401830+12 (66.7% more)

    The uniform example as minified JSON

    {"users":[{"id":1,"name":"Ada Lovelace","role":"admin","active":true,"score":98.5},{"id":2,"name":"Grace Hopper","role":"editor","active":true,"score":91},{"id":3,"name":"Alan Turing","role":"viewer","active":false,"score":87.25},{"id":4,"name":"Edsger Dijkstra","role":"editor","active":true,"score":94},{"id":5,"name":"Barbara Liskov","role":"admin","active":true,"score":99}]}

    The same data as TOON

    users[5]{id,name,role,active,score}:
      1,Ada Lovelace,admin,true,98.5
      2,Grace Hopper,editor,true,91
      3,Alan Turing,viewer,false,87.25
      4,Edsger Dijkstra,editor,true,94
      5,Barbara Liskov,admin,true,99

    TOON gotchas

    Tabular arrays need identical keys and plain values

    The table form with a {id,name} header is used only when every record has the same keys and primitive values. When one record is missing a key, the whole array falls back to the longer list form. Three records with one key left out came out like this:

    rows[3]:
      - id: 1
        n: a
      - id: 2
        n: b
      - id: 3

    Strings are quoted only when needed

    Here is how a few strings were written: s: "a,b" | t: " lead" | n: "true" | m: "12" | u: cafรฉ ไปŠๆ—ฅ | plain: hello world. Text that looks like a number or a boolean, has leading spaces, or contains the delimiter is quoted, while accented and CJK text stays as it is.

    Empty containers

    An empty array is written as e: [] and an empty object as a key with nothing after it. Reading it back gave {"e":[],"o":{},"s":""}, so both survive the trip.

    Numbers are written in canonical form

    The input 1e5, 1.0, -0 and 1e-7 came out as a: 100000 | b: 1 | c: 0 | d: 1e-7. The values are equal, but the original spelling is not kept, and negative zero becomes zero.

    Big integers are kept exactly

    A browser reads JSON numbers as 64-bit floats, which would turn the id 12345678901234567890 into 12345678901234567000. This page swaps integers beyond 2^53 for placeholders before parsing and puts the exact digits back afterwards, in both directions, and a notice above the result counts them. The id came out as id: 12345678901234567890 and read back unchanged. If the page cannot confirm it kept them, it falls back to the plain conversion and warns that numbers may lose digits. Decimals are still floats: 12345678901234567890.5 came out as d: 12345678901234567000.

    The delimiter changes the header

    With a tab or a pipe delimiter the header and rows use that character instead of a comma, which helps when values contain commas. The pipe version of a small table reads users[2|]{id|name}:.

    Strict reading checks counts and indentation

    By default the TOON reader checks that declared lengths match. The text items[3]: a,b was refused with "Expected 3 inline-form values, but got 2", and with Strict switched off it was read as two items. An indent that is not a multiple of the chosen size is refused too, so the indent option must match the text.

    Deep nesting, special keys and odd strings

    Nesting 500 levels deep converts, while tens of thousands of levels stop with a message that the data is nested too deeply. Keys named __proto__ and constructor are kept as ordinary keys when reading TOON. A string holding an unpaired surrogate, which valid JSON can contain, is refused with the library's message instead of being changed.

    Round trips

    All five examples above came back from TOON to the same JSON data. Differences come from the canonical number form of decimals, not from the structure.

    Is my data uploaded?

    No. Your JSON never leaves your browser. Conversion runs in a background worker on this page, using a copy of the open-source @toon-format/toon library served from this site. The tokenizer file is loaded from this site, and only when you press Compare tokens, to count tokens in the browser.

    Frequently Asked Questions

    What is TOON?

    TOON, short for Token-Oriented Object Notation, is a text format that holds the same data as JSON in a more compact layout, aimed at prompts for language models. It is young: its specification is a working draft, and this page uses version 4.4 of the open-source library.

    How do I convert JSON to TOON?

    Paste your JSON or upload a file, keep JSON to TOON selected, and the TOON appears as you type. Choose the indent and delimiter, then copy or download it. Switch to TOON to JSON to go back, and press Compare tokens to see the token counts.

    Does TOON always use fewer tokens than JSON?

    No. It helps most with long arrays of records that share the same keys. In the examples on this page, the uniform array used fewer tokens, while the nested and mixed examples used more than minified JSON. Press Compare tokens on your own data to find out.

    Is the token comparison exact?

    It is exact for OpenAI models that use the o200k_base encoding, such as GPT-4o and GPT-4.1. Other models, including Claude and Gemini, use their own tokenizers and will count differently. The LLM Token Counter on this site shows more models, with estimates clearly labelled.

    Is my data uploaded anywhere?

    No. Your JSON never leaves your browser. Conversion runs in a script on this page, using a copy of the open-source library served from this site. The tokenizer file is loaded from this site only when you press Compare tokens.

    Built and maintained by Deepak Kumar. Your JSON never leaves your browser.