Skip to main content
Back to tools

JSON Minifier

Minify and prettify JSON documents

About JSON Minifier

Minifies JSON onto a single line or pretty-prints it with 2-space indentation, with a readout of how much smaller the minified version is. The input goes through JSON.parse and JSON.stringify, so it must be strict JSON, whitespace inside string values is kept, and the output always parses. Handy for shrinking fixtures, API payloads or config before embedding them in code.

Category: Minifiers.

Frequently asked questions

What is the difference between minifying and formatting JSON?

▾

Minifying removes all unnecessary whitespace to reduce file size — ideal for API responses and production bundles. Formatting adds indentation and newlines for human readability — ideal for config files and debugging.

Does minifying change the data?

▾

Not for typical JSON, but the tool rebuilds the text from the parsed value instead of just deleting spaces. As a result, repeated keys keep only the last value, integers larger than 2^53 are rounded (a problem for 64-bit IDs), and numbers are rewritten in JavaScript's standard notation, so 1.0 becomes 1 and 1e3 becomes 1000.

How much can JSON be reduced?

▾

It depends on the indentation: deeply nested, pretty-printed JSON shrinks the most, and the tool shows the exact percentage and the size before and after. For API payloads, also enable GZIP or Brotli compression, which saves far more because JSON repeats the same keys.

Why do I only get an "Invalid JSON" error?

▾

The input must be strict JSON, so comments, trailing commas, single quotes and unquoted keys are rejected, even though JSONC files such as tsconfig.json or JSON5 files may contain them. The minifier doesn't say where the problem is; paste the text into the JSON Validator to see the parser's message for the first error.

Related tools