jsondecode.com logo

JSON Minifier

Remove all whitespace from JSON to produce the smallest possible output. Runs entirely in your browser — no data sent to any server.

What is JSON minification?

JSON minification removes all whitespace characters — spaces, newlines, and tabs — that are not part of string values. The resulting JSON is semantically identical: all keys, values, arrays, and nesting are preserved, but the file is as compact as possible.

Minified JSON is used in production APIs and web applications to reduce payload size and improve transfer speed. A typical pretty-printed JSON file is 20–40% larger than its minified equivalent. For high-traffic APIs serving millions of requests, minifying JSON responses meaningfully reduces bandwidth costs and latency.

This tool parses your JSON first to validate it, then re-serializes it without any whitespace using JSON.stringify(parsed). Invalid JSON is rejected with an error message — you can't minify what you can't parse.

When to minify JSON

  • API responses — minify JSON before sending over HTTP. Combine with gzip/Brotli compression for maximum reduction (whitespace compresses well, so the combined savings are significant).
  • Configuration files in source control — minify large JSON config files to reduce diff noise and file size.
  • Cookies and localStorage — minify JSON before storing in browser cookies (4KB limit) or localStorage.
  • Embedded JSON in HTML — minify JSON injected into <script> tags or data- attributes to reduce HTML size.
  • Build pipelines — minify JSON assets (translation files, config) as part of a production build step.

Minify JSON in code

JavaScript / Node.jsJSON.stringify(JSON.parse(jsonString))
Pythonimport json; json.dumps(json.loads(json_string), separators=(',', ':'))
Goimport bytes; var buf bytes.Buffer; json.Compact(&buf, []byte(jsonString))
PHPjson_encode(json_decode($jsonString))
Rubyrequire 'json'; JSON.parse(json_string).to_json
Bash (jq)echo '$json' | jq -c .
Bash (Python)python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin),separators=(',',':')))"

Frequently asked questions

Does minifying JSON change the data?

No. Minification only removes insignificant whitespace — spaces, tabs, and newlines between tokens. All keys, values, nesting, and ordering are preserved exactly. The minified JSON parses to an identical JavaScript object.

Does minification work with JSON arrays?

Yes. Any valid JSON value can be minified — objects, arrays, strings, numbers, booleans, and null. Paste an array or a deeply nested document and the tool handles it.

What is the difference between JSON minify and JSON compress?

Minification removes whitespace (lossless, within the JSON format). Compression (gzip, Brotli, zstd) further reduces size by encoding repeated byte patterns. Most web servers apply gzip on top of minified JSON automatically via content-encoding. For best results, do both: minify first, then let your server compress.

Why does minified JSON still have spaces inside strings?

Whitespace inside JSON string values is part of the data — removing it would change the content. Only whitespace between tokens (after colons, after commas, between brackets) is removed. For example, " hello world " keeps its spaces; the key: value separator does not.

Can I minify JSON from the command line?

Yes — jq is the most common tool: echo '{"a": 1}' | jq -c . The -c flag outputs compact (minified) JSON. You can also use Python: python3 -c "import sys,json; print(json.dumps(json.load(sys.stdin),separators=(',',':')))" < file.json

If jsondecode.com saved you time, share it with your team

Free forever. No ads. No sign-up. Help other developers find it.