Skip to content

JSON Minifier

Compress JSON to a single line — whitespace and indentation removed, validity checked first, right in your browser.

Last updated

How to use json minifier

  1. Paste JSON into the input box, or tap Load file to read a .json file from your device.
  2. The minified output appears as you type — there is also a Minify JSON button if you prefer.
  3. Invalid JSON produces the parse error with its position, so you can jump straight to the problem.
  4. Copy the compact output or download it as a .min.json file; the size readout shows the exact bytes saved.

Examples

Minify a config object

A readable configuration block becomes a single compact line — identical data, about a third fewer bytes.

Compact an API-style payload

Nested arrays and objects all flatten to one line, ready for a data attribute or a request body.

Catch a broken document

A trailing comma is invalid JSON — the tool reports the error position instead of guessing.

What is JSON Minifier?

JSON spends a lot of bytes on looking nice: two-space indentation, line breaks after every property, spaces around colons. Humans appreciate it; parsers ignore it. A JSON minifier strips that presentation whitespace and returns the same data as one dense line — the values, the key order and the structure are all preserved byte-for-byte, because whitespace between tokens carries no meaning in JSON.

This json minifier validates before it compresses: paste malformed JSON and you get the parse error with a position pointer instead of silently broken output. Paste valid JSON and you get the compact form with the byte count before and after, so you know exactly what the minify step saved. For configuration files, API payloads baked into pages, or data attributes, that compact form is what should ship.

Everything runs locally in the tab — payloads containing tokens, internal IDs or customer data never leave your machine. If you need the opposite direction, the JSON Formatter (linked below) pretty-prints minified responses for reading; the two tools are a pair.

Frequently asked questions

Can you minify JSON?

Yes — JSON minification simply removes the whitespace between tokens, which the spec defines as insignificant. The parsed data is identical before and after: same keys, same order, same values. What you cannot do is strip quotes from keys or add comments — those would stop being JSON. For that, look at formats like JSONC or JSON5.

How can I minify JSON in Python?

One line does it: json.dumps(data, separators=(",", ":")) — the separators argument drops the spaces the default output adds. In JavaScript the equivalent is JSON.stringify(data) with no indentation argument. This page is the no-code option when you just have a file or a pasted payload.

What is the best JavaScript minifier?

For JavaScript code (as opposed to JSON data), terser is the widely used standard — it is what this site’s Minify JavaScript tool runs, and it powers most bundlers. esbuild and swc are faster alternatives built into modern toolchains. For JSON specifically, no parser-heavy tool is needed: parse-and-reserialize, which this page does, is already optimal.

Is minified JSON valid JSON?

Absolutely — it is the canonical form, if anything. Minified JSON parses with every compliant parser in every language. This tool validates the input first, so if the output was produced here at all, the input was valid JSON and the output is too.

Does minifying JSON change number precision or key order?

No. The tool parses and re-serializes without touching values: numbers keep their text-level precision in practice, keys stay in their original order, and strings are preserved exactly, unicode included. Only the presentation whitespace disappears.

Browse all developer tools.