JSON Minifier
Strip every byte of insignificant whitespace to shrink JSON for transport, storage or embedding.
Your JSON
Minified JSON
Pretty-printed JSON is typically 20 to 50 per cent whitespace, and occasionally far more — a deeply nested document indented with four spaces can be more indentation than data. That is free to ignore when a human is reading it and expensive when it is a request body on a metered mobile connection, a value crammed into a database column with a length cap, or a config string being passed through an environment variable that hates newlines.
This minifier parses the document and re-serialises it with no separators at all, which is safer than the regular-expression approach most quick scripts use. A regex that deletes whitespace outside quotes gets it wrong the first time it meets an escaped quote inside a string; parsing cannot. Whitespace inside your string values is untouched, because there it is data.
How to use the json minifier
- 1
Paste the formatted JSON
Paste, drop or upload the document you want to compress. Anything up to 10 MB is fine.
- 2
Minify
The output pane shows the single-line result. If the input is not valid JSON the minifier stops and reports the line and column instead of producing a compact but broken string.
- 3
Copy or download
Take the compact form straight to your clipboard, or download it as a
.jsonfile ready to ship.
What is removed and what is preserved
Removed: every space, tab, carriage return and newline that sits between tokens — after a colon, after a comma, inside otherwise empty braces. This is the whitespace JSON explicitly defines as insignificant, so nothing that consumes the output can tell the difference.
Preserved exactly: all string content, including spaces, newlines encoded as \n, tabs and unicode escapes. Key order, array order, and every value are unchanged. An empty object stays {} and an empty array stays [].
Because minifying is a parse-and-reprint, the same normalisations apply as in the formatter: number literals lose redundant spelling (1.0 becomes 1), decodable unicode escapes are written as literal characters, and duplicate keys collapse to their last value. The data is identical; the bytes are not a strict subset of the original.
How much you actually save
For typical two-space-indented API output, expect a 20 to 40 per cent reduction. Documents with many short keys and shallow values do best, because indentation is a large share of every line. A flat array of numbers barely shrinks at all — there was almost no whitespace to begin with.
It is worth being honest about where minification stops mattering. If your transport already uses gzip or Brotli, as essentially every HTTP API does, compression eliminates most of the repeated indentation anyway, and minifying first typically buys only a few extra per cent on the wire. The cases where it genuinely pays are the ones where compression is not available: a value stored in a database column, a JSON blob embedded in another document, a payload counted against a hard request-size limit, or a string passed through a shell or an environment variable.
Minified JSON is also the wrong thing to commit to version control. A single-line file produces a diff that says "line 1 changed" for every edit, which destroys code review.
Where minification belongs, and where it does not
The useful rule is that minified JSON is a transport and storage form, never a source form. Keep the readable version in your repository, minify at the point of use, and never hand-edit a minified file — the moment you do, you have made an unreviewable change to something nobody can read.
Concrete places it earns its keep:
- Static data shipped to a browser. A lookup table or a translation bundle loaded on first paint, where every kilobyte is on the critical path.
- Database and cache values. A JSON blob in a
TEXTorJSONBcolumn, or a Redis value, where indentation is pure overhead multiplied by row count. - Embedded strings. JSON inside a JSON field, inside a YAML value, inside an environment variable — anywhere newlines have to be escaped or would break the enclosing syntax.
- Hard payload limits. Webhook bodies, message-queue payloads, serverless request caps and SMS-adjacent channels that count characters rather than compressed bytes.
- Canonical logging. One event per log line means one JSON document per line, which is the whole premise of NDJSON and of every log shipper built around it.
And where it does not belong: anything a human maintains, anything under version control, anything a colleague will be asked to review, and any file whose readability is worth more than the handful of kilobytes you would save.
JSON Minifier FAQ
Can I reverse minification?
Yes — paste the output into the JSON Formatter and it expands again. The round trip is lossless for your data; the only thing not recovered is the original indentation style, which was never part of the document's meaning.
Does minifying change what my JSON means?
No. Only whitespace between tokens is removed, and JSON defines that whitespace as insignificant. Every consumer that accepted the original will accept the minified form.
Why not just use a find-and-replace to strip whitespace?
Because a naive replace will also strip spaces inside your string values, corrupting the data. Anything sophisticated enough to avoid that has to track whether it is inside a string and handle escaped quotes — at which point you have written a parser. This tool uses the real one.
Does minifying help with gzip?
Marginally. Repeated indentation compresses extremely well, so gzip has already removed most of that cost. Minify when compression is not in play — database columns, embedded strings, hard payload caps — rather than as a reflex on every HTTP response.
Will minifying break my file if it is not valid JSON?
It will not try. The document is parsed before anything is written, so invalid input produces an error with a line and column rather than a compact string that still contains the original fault. If the input is broken on purpose — LLM output, a config with comments — repair it first, then minify.
Is my JSON uploaded to a server?
No. Parsing and re-serialising both happen in a Web Worker in your own browser, so payloads containing tokens, personal data or internal hostnames never leave your machine. There is no server-side component to receive them.
