JSON Minifier
Strip whitespace from JSON to shrink payload size.
Was this tool helpful?
Thanks for the feedback!
The JSON Minifier removes every space, tab and line break that sits outside string values, turning pretty-printed JSON into a single compact line. The data stays the same; only the layout disappears. It is handy for API payloads, test fixtures, environment variables and anywhere JSON has to fit on one line.
Example and saving
A 107-character profile:
{
"name": "Asha Verma",
"city": "Mumbai",
"skills": [
"SQL",
"Python"
],
"active": true
}
becomes 77 characters, 28% smaller:
{"name":"Asha Verma","city":"Mumbai","skills":["SQL","Python"],"active":true}
The space inside "Asha Verma" is kept, because whitespace inside a string is part of the data. Deeply indented files save much more than this small sample, since every nested level adds two spaces to each line.
Where one-line JSON is needed
- Environment variables and CI secrets, where a value must be a single line, for example a JSON config passed to a container.
- HTML data attributes and inline scripts, such as JSON-LD structured data or settings passed to a widget.
- Logs and message queues, where the common JSON Lines format expects each record on exactly one line.
- Database columns and API requests, where fewer bytes mean less storage and faster transfer.
The minifier also validates
The input is fully parsed before it is written out again, so invalid JSON is never "minified" into something broken; you get the parser's error message instead. That has a side effect worth knowing: files that allow comments, such as VS Code's settings.json or a tsconfig.json with notes in it, are rejected, because comments aren't part of standard JSON. A comment on line 2 produces an error pointing at "line 2 column 3". Remove the comments first.
Changes beyond whitespace
Because the data is parsed into JavaScript values and serialised again, a few things can change:
- Numbers are rewritten in their shortest form, so
2.50becomes2.5. - Integers larger than 9,007,199,254,740,991 lose their last digits.
- A key that appears twice in the same object keeps only its final value.
- Unicode escapes such as
\u20b9are written out as the actual character (₹).
For most data none of this matters, but for financial amounts or 64-bit IDs, store the values as strings.
Keep the pretty-printed version in version control, though. Git compares files line by line, so a change to one value in a minified file shows up as the entire file changing, while an indented file shows exactly which line was edited. Minify only the copy you deploy or send.
Minifying runs in your browser. To get readable JSON back, paste the result into the JSON Formatter; to check a document without changing it, use the JSON Validator.