About JSON Minifier
Whitespace makes JSON readable and adds bytes that a machine never looks at. Minifying removes it, which helps when a value has to fit in an environment variable, a single log line, a query parameter, a fixture or a request body you are pasting into a terminal.
You get one line, and a status line such as 166 B to 126 B, 24% smaller. Malformed input is rejected with its line and column, so you never get a compact copy of something that was already broken.
How it works
Only the spaces, tabs and line breaks between tokens are removed. The text is read by the same strict parser the other JSON tools here use, then written back with no separators beyond commas and colons. Whitespace inside strings is part of your data and stays.
Nothing is reinterpreted along the way. A value of 1.50 is not shortened to 1.5, \u00e9 is not turned into an accented letter, and key order is unchanged. That means the output decodes to exactly what the input does, and a hash of it only differs because the spacing differs.
How to use JSON Minifier
- Paste into the JSON to minify box, or press Upload. Try an example shows it on a small config.
- The compact result appears straight away, with the size before and after underneath.
- Press Copy, or Download to save
minified.json.
A small config, compacted
{
"name": "api-gateway",
"version": "2.4.1",
"price": 1.50,
"routes": [
{ "path": "/users", "auth": true },
{ "path": "/health", "auth": false }
]
}{"name":"api-gateway","version":"2.4.1","price":1.50,"routes":[{"path":"/users","auth":true},{"path":"/health","auth":false}]}The input is 166 bytes and the output 126. Look at price: it is still 1.50, because the number is carried over as text.
When it helps
- Putting a JSON config into a single environment variable or secret
- Fitting a test payload on one line of a shell command
- Reducing a fixture committed to a repository, when nobody needs to read it
- Writing a JSON Lines file, where each record has to be on its own single line
Tips for a better result
- Do not count on minifying alone to speed up an API. Compression such as gzip or Brotli removes most of the same repetition, so the gain over the network is usually far smaller than the figure shown here.
- Keep the formatted original in version control and generate the minified copy. One-line files make diffs unreadable.
- If the result is going into a URL, run it through URL Encode Decode next, since braces and quotes are not safe there.
Good to know
- It only removes whitespace. It does not shorten keys, drop nulls or change number formats, so savings depend on how much indenting the file had.
- Comments and trailing commas are errors here, so JSONC files need those removed first.
- The result is a single line, which editors can struggle with once it reaches many megabytes.
- A file over 5 MB is refused by Upload, though pasting one still works.
Questions people ask
Is minified JSON still valid JSON?
Yes. Whitespace between tokens is optional in the standard, so any parser reads the two forms identically.
Does it change spaces inside my strings?
No. Only whitespace outside strings is removed. A value like "New York" keeps both of its spaces.
How much smaller will my file get?
It depends on the indenting. Deeply nested data formatted with 4 spaces shrinks a lot, and a file that is already mostly one line barely changes. The status line reports the real figure for your input.
Can I reverse it?
Yes, and no information is lost. The JSON Formatter gives you the indented version back, though any custom alignment you had is not recovered.
What to use next
- JSON Formatter: to expand a minified file so you can read it
- URL Encode Decode: when the compact JSON has to travel inside a URL
- Base64 Encode Decode: to wrap the result for a config value that cannot hold quotes
Last reviewed . Read our editorial policy.