JSON Minifier
Collapse pretty-printed JSON back to a single compact line — every value preserved exactly — and confirm it's valid in the same pass.
What minifying JSON means
Pretty-printed JSON is full of whitespace that exists purely for humans — the indentation, the line breaks, the space after each colon. None of it carries any data. A JSON minifier removes all of it, producing the most compact representation of exactly the same object.
The mechanism is a clean round-trip: the tool runs JSON.parse() on your input and then JSON.stringify() with no indentation argument. Because parsing comes first, minifying doubles as validation — if your JSON has a trailing comma, a single quote, or any other syntax error, it's reported instead of being silently mangled.
Your data never leaves the browser, so it's safe to minify API responses or config files that contain tokens and keys.
Minifying JSON in four steps
- 1
Paste your JSON
Add formatted or messy JSON to the input pane, or upload a .json file.
- 2
Watch it compact
Whitespace is stripped automatically and the single-line result appears on the right.
- 3
Fix any errors
If the JSON is invalid, you'll see a clear message so you can correct the syntax.
- 4
Copy or download
Take the compact JSON to your clipboard or save it as a .json file.
When compact JSON pays off
Lighter API payloads
Stripping whitespace shaves bytes off every request and response, which adds up at scale.
Free validity check
Because the JSON is parsed first, a syntax error is caught the moment you paste it.
Embeddable strings
Single-line JSON is easy to drop into a config value, environment variable, or data attribute.
Nothing leaves the browser
Payloads containing secrets or keys are processed locally and never uploaded.
Before and after
Indented JSON on the left; the compact single line on the right.
{
"user": {
"id": 42,
"name": "Ada",
"roles": ["admin", "dev"],
"active": true
}
}{"user":{"id":42,"name":"Ada","roles":["admin","dev"],"active":true}}How much smaller does it get?
The savings depend entirely on how heavily indented the input was. Deeply nested JSON with four-space indentation can shrink dramatically, since every level of nesting multiplies the whitespace. Already-compact JSON barely changes. Either way the data is identical — minifying only ever removes insignificant whitespace, never a single byte of your actual content.
What is and isn't preserved
- Every key, value, array element and nesting level is preserved exactly.
- Key order is kept as your input had it.
- Number, string, boolean and null types are unchanged.
- Only insignificant whitespace — indentation and line breaks — is removed.
Frequently asked questions
No. Keys, values, types and ordering are all preserved. The only thing removed is insignificant whitespace — indentation and line breaks.
The tool parses your input before minifying. Common causes are trailing commas, single quotes instead of double, unquoted keys, or comments — none of which are legal JSON. Fix the flagged issue and try again.
Yes. Run the compact JSON through our JSON Beautifier to get an indented, readable version. Since no data is lost during minifying, the round-trip is lossless.
No. Standard JSON has no comment syntax, so // and /* */ both cause a parse error. Remove comments before minifying, or use a JSON5-aware tool if you need them.
Never. Parsing and stringifying happen entirely in your browser, so payloads with tokens or keys stay on your machine.
No. The tool preserves the key order exactly as it appears in your input — it doesn't sort or reorder anything.
Need another tool?
Browse the full toolbox or dig into the blog for the engineering behind it.