JSON Minifier

Remove every space, tab and line break that JSON does not need and get the smallest equivalent document on one line. The input is validated first, so you never ship broken JSON.

Input
Output

    Nothing leaves your browser. Shortcut: Ctrl/⌘ + Enter runs the main action.

    What is JSON minification?

    Minifying JSON means removing all whitespace that is not inside a string: indentation, line breaks and spaces after colons and commas. The result is one line that any JSON parser reads to exactly the same data as the original. JSON's grammar in RFC 8259 allows whitespace around every structural character but gives it no meaning, which is why the transformation is safe and reversible: you can pretty-print the output again with the JSON formatter at any time.

    How to minify JSON

    1. Paste the JSON or open a file. It is validated as you type.
    2. Optionally tick Sort keys for a canonical, order-independent form.
    3. Click Minify. The single-line result appears on the right with the original size, the new size and the percentage saved.
    4. Copy or download the result.

    Example

    {
      "id": 42,
      "tags": [ "a", "b" ],
      "note": "two  spaces stay"
    }

    minifies to {"id":42,"tags":["a","b"],"note":"two spaces stay"}. The double space inside the string is preserved because it is part of the value.

    When minifying is worth it

    For responses served over HTTP with gzip or Brotli, minifying gives a smaller gain because compression already removes most of the repeated whitespace. It is still cheap to do in a build step.

    Why validate before minifying?

    A minifier that only deletes whitespace with a regular expression will happily turn broken JSON into broken JSON on one line, which is even harder to debug. This tool parses the input first. If it is invalid you get the list of problems with line numbers from the original, readable layout, and the minified output is produced only from a correct document. Numbers are copied exactly as written, so values beyond JavaScript's precision such as 12345678901234567890 are not rounded.

    JSON minifier questions

    How much smaller does minified JSON get?

    It depends on how the input was formatted. JSON indented with 2 spaces typically shrinks by 15–30%, with 4 spaces or tabs by 25–40%. The status line shows the exact before and after sizes.

    Is minified JSON still valid JSON?

    Yes. Whitespace between tokens is insignificant in JSON, so a minified document parses to exactly the same data. Whitespace inside strings is part of the value and is never touched.

    Should I minify JSON for an API if I use gzip?

    Gzip or Brotli compression removes most of the cost of indentation, so the gain from minifying is smaller on the wire, typically a few percent. It still helps for JSON stored in databases, sent in query strings or headers, embedded in HTML, or kept in memory.

    Can I minify and sort keys at the same time?

    Yes. Tick Sort keys before clicking Minify. Sorted, minified JSON is a simple canonical form that is handy for hashing, caching keys or comparing documents.

    Does minifying remove comments?

    Comments are not part of JSON, so a file with comments is invalid and must be repaired first. Click Fix JSON to remove them (along with trailing commas and other non-standard syntax), then minify.