Quick answer
Minifying JSON removes every optional whitespace character — the spaces, tabs, and newlines between tokens — leaving valid JSON on a single line. The data, keys, order, and structure are untouched; only presentation changes. It runs entirely in your browser via JSON.parse() then JSON.stringify(), so nothing is uploaded. Paste JSON, click Minify, then copy or download.
How JSON Minification Works
- Your JSON is first parsed with
JSON.parse()— if the input is invalid, minification fails and the error is shown so you can fix it first. - The parsed result is then serialised with
JSON.stringify(parsed)using no indentation argument, producing the most compact valid JSON string. - All whitespace between tokens — spaces, tabs, and newlines — is stripped. No data values, keys, or structure are changed.
- Everything runs in your browser; no data leaves your machine.
When to Minify JSON
- When deploying a JSON payload to a production API endpoint where every kilobyte affects response time and bandwidth cost.
- When storing JSON in a database column or cache key to reduce storage overhead.
- When embedding JSON in JavaScript source files or HTML pages and bundle size matters.
- When serving static JSON files over a CDN — minifying first, then enabling gzip compression at the server level gives the best results.
Worked example
The same object formatted and then minified — notice that only whitespace disappears:
Input (formatted)
{
"name": "Alice",
"roles": ["admin", "editor"],
"active": true
}
Output (minified)
{"name":"Alice","roles":["admin","editor"],"active":true}
What happened
- Every newline and every space between tokens (after each
:and,, and around brackets) was removed, collapsing the object onto one line. - The keys, the string
"Alice", the array items, and the booleantrueare all unchanged — the space inside a value like"New York"would be kept, because it is not whitespace between tokens. - Here the formatted form is 71 bytes and the minified form is 57 bytes; the savings grow with deeper nesting and larger indentation.
Edge cases & gotchas
- Minifying is not compression. It only strips optional whitespace (typically 10–30% smaller). Server-side gzip or brotli shrinks JSON 70–90% by compressing repeated keys and values too — so minify and enable gzip; the latter does most of the work over the wire.
- Whitespace inside strings is preserved. Only whitespace between tokens is removed, so
"first name"keeps its space. Nothing inside a quoted value is touched. - Numbers are normalized. Parsing and re-serializing rewrites numbers to canonical form:
1.0→1,100.00→100,1E2→100. The value is identical; only the text changes. Keep version-like values as strings if exact text matters. - Key order is preserved for normal string keys, so a minified file diffs cleanly against a formatted one after re-formatting.
- Invalid input won't minify. Because it parses first, a trailing comma or unquoted key fails with an error rather than producing broken output — fix the JSON, then minify.
Frequently Asked Questions
Will minifying JSON change the data?
No. Minification only removes whitespace and formatting characters, it does not change the JSON values.
Can I undo minification?
Yes. Paste the minified JSON into the formatter page to restore readable indentation.
Is minified JSON good for production?
Yes. Minified JSON is ideal for production because it reduces payload size and improves transfer speed.
Should I minify JSON during development?
No — keep JSON formatted and readable during development so you can inspect and debug it easily. Minify only as part of your build or deploy step before shipping to production.
Does minifying JSON make it invalid?
No. Minified JSON is always valid JSON as long as the input was valid. Whitespace between tokens is optional according to the JSON specification — removing it does not affect any parser.
Is minifying better than gzip for reducing size?
No — they do different jobs, and gzip does far more. Minifying only removes optional whitespace, usually saving 10–30%. Server-level gzip or brotli compression, which most web servers and CDNs enable, typically shrinks JSON by 70–90% because it also compresses repeated keys and values. The best result is to minify and enable gzip; once gzip is on, minification alone adds only a small extra saving over the wire.
Can minifying change my numbers?
Slightly, in representation only, never in value. Because this tool parses then re-serializes, numbers are normalized to their canonical form — 1.0 becomes 1, 100.00 becomes 100, and 1E2 becomes 100. The numeric value is identical, but if you rely on the exact text of a number (for example a version string), store it as a JSON string instead.