LocalToolkit
HomeData Converters › JSON Minifier

JSON Minifier

Removes formatting whitespace only — never a character inside a string.

🔒 Runs in your browser. Nothing is uploaded — verify it in the network panel, or disconnect and try again.

Which whitespace is safe to remove

JSON allows spaces, tabs, carriage returns and line feeds between tokens, and nowhere else. Whitespace inside a string literal is data and must survive byte-for-byte: minifying {"msg": "a b"} must not collapse the two spaces to one. A correct minifier therefore parses the document and re-serialises it, rather than running a regular expression over the text. Regular-expression minifiers silently corrupt strings that contain //, /* or quote characters.

What minification actually buys you

PayloadPrettyMinifiedGzipped pretty
Small API object~20% largerbaselinewithin 1–3% of minified
1 MB config dump~15% largerbaselinewithin 1–2% of minified
Embedded in a URL or cookiematters directlybaselinenot applicable — no compression
Stored in memory for a cache keyirrelevantbaselinenot applicable

The pattern is consistent: minification saves real bytes only where compression is unavailable — URLs, cookies, small inlined scripts, and byte-counted storage. Over HTTPS with gzip or Brotli, it is close to a rounding error.

The real reasons to minify

Minified JSON is not the same as JSON Lines. Minifying an array keeps it one JSON value spanning one long line; JSON Lines is many independent JSON values, one per line, which is what streaming tools actually want. Confusing the two breaks line-based processors.

Round-trip safety

Minification here is done by parsing to a value and re-serialising. That means the output is guaranteed to be valid JSON, and any input that cannot be parsed produces an error instead of a partially-processed string. Two consequences worth knowing: numbers may be re-rendered in a normalised form (1.0 becomes 1, 1e2 may become 100), and duplicate keys collapse to the last value. Both are artefacts of parsing, and both are silently different from the input.

How to use it

  1. Paste the JSON document.
  2. Minify.
  3. Check the reported reduction in bytes and percentage.
  4. Copy the single-line result.

Worth knowing

  • Whitespace inside string literals is data and is preserved exactly.
  • Compression already removes most of the benefit over an HTTPS response.
  • Numbers may be re-rendered in a normalised form because the document is re-parsed.
  • Output is guaranteed parseable, or an error is reported.

Limitations

  • Comments cannot be preserved — they are not legal JSON to begin with.
  • Duplicate keys collapse to the last value, as parsing dictates.
  • Number formatting may change even when the value does not.
  • Extremely large documents are limited by tab memory.

Frequently asked questions

Does minifying change my data?
String contents are preserved exactly. Two things can change as a side effect of parsing: number rendering (1.0 prints as 1) and duplicate keys, where the last value wins and the earlier ones disappear.
Will minifying break my JSON?
Not here — the output is re-serialised from a parsed value, so it is valid by construction. The failure mode is the opposite: invalid input is rejected rather than silently mangled.
How much smaller does it get?
Typically 10 to 20 percent against pretty-printed JSON, and near zero if the payload is already gzipped. The gains are real only where compression is not available.
Can I use a regex to minify JSON instead?
You can, and it will work until a string contains // or a quote character, at which point it silently corrupts the document. Parse and re-serialise instead.
Related tools
JSON Formatter & ValidatorJSON to CSV ConverterJSON to YAML ConverterJSON to XML ConverterCSV to JSON ConverterYAML to JSON Converter
Keep reading
How browser-only processing worksAll Data Converters toolsEvery tool on the site