"category": "utility",

JSON Minifier

"tldr": Paste formatted JSON and get the smallest valid version - all whitespace stripped, meaning unchanged, typically 20-40% smaller.

Minify JSON to its smallest valid form: all indentation, spaces, and line breaks outside of strings are removed. The input is validated first, so a syntax error is reported instead of silently producing broken output.

{"json": "minified json"}

Minified JSON is byte-identical in meaning to the pretty version - whitespace between tokens carries no data. Typical formatted documents shrink by 20-40%, which matters for payloads served without compression, config baked into bundles, and storage quotas.

How to minify JSON

  1. 1Paste your formatted JSON into the input panel.
  2. 2The tool validates it and reports any syntax error with its position.
  3. 3Valid JSON is re-serialized with zero inter-token whitespace.
  4. 4Copy the single-line result or download it as a .json file.

Convert JSON to Minified JSON in code

JavaScript
const minified = JSON.stringify(JSON.parse(text));
Python
import json

minified = json.dumps(json.loads(text), separators=(",", ":"))

Frequently asked questions

Does minifying change the data at all?

No. JSON ignores whitespace between tokens, so parsers see exactly the same document. Whitespace inside string values is data and is always preserved. Note that key order is kept but numbers are re-serialized canonically (e.g. 1.50 becomes 1.5).

Is minification worth it if my server uses gzip?

Gzip already compresses repeated whitespace extremely well, so the on-the-wire savings on top of gzip are small (a few percent). Minification matters most where compression is absent: inline config in code bundles, localStorage, and size-limited fields.

How do I un-minify (pretty-print) JSON?

Use our JSON Formatter tool, or in code: JSON.stringify(JSON.parse(text), null, 2) in JavaScript, json.dumps(json.loads(text), indent=2) in Python. Minification is fully reversible except for the original formatting style.

Can minified JSON contain comments or trailing commas?

No - those are invalid JSON before and after minification. If your source is JSONC (config with comments), strip comments with a JSONC-aware tool first; this minifier enforces strict JSON.

Last updated:

You might also need

Free and in-browser, like everything on JSON Console. Browse all tools →