Guides Knowledge Base

JSON Compressor Online

Free online JSON compressor. Strip every space, tab and newline outside strings to cut payload size 20–60% before Gzip, with data left byte-identical.

Compressing JSON means removing the whitespace a human added for readability. Every space, tab, and newline outside a string literal is stripped, collapsing the document to one line. Keys, values, types, and order stay identical — only the byte count drops.

Whitespace Removal vs Gzip

These are different layers and they compound. Whitespace removal is lossless at the JSON level and typically saves 20–60% of raw bytes. Gzip or Brotli then compresses what remains at the transport level. Minifying first gives the compressor less redundancy to encode, so the compressed result is usually smaller too — though by a narrower margin than the raw saving suggests.

What Compression Does Not Change

  • Whitespace inside string values — {"note": "two spaces"} is preserved exactly.
  • Key order, array order, numeric precision, and null values.
  • Unicode escapes and the document's semantic meaning.

Compressing JSON in Code

# jq, compact output
jq -c . input.json > output.min.json

# Python
python3 -c "import json,sys; json.dump(json.load(sys.stdin), sys.stdout, separators=(',',':'))"

// Node.js
JSON.stringify(JSON.parse(raw));

Where the Savings Come From

Deeply nested, heavily indented documents save the most, because every level of nesting adds indentation to every line. A flat array of short objects saves the least. Documents dominated by long string values barely shrink at all — there is little whitespace between tokens to remove.

Who this guide is for

  • Cut the size of a JSON response before it goes over a mobile connection
  • Shrink a config bundle shipped inside a JavaScript build
  • Reduce the footprint of documents written to a cache or a JSON column
  • Trim a fixture file that bloated a repository

Try the free JSON Minifier

Runs entirely in your browser — no upload, no signup, and your data never leaves your device.

Open JSON Minifier

Frequently Asked Questions

Is JSON compression lossless?

Yes. Only insignificant whitespace between tokens is removed. Parse the compressed output and you get a structure identical to the original.

Should I compress JSON if my server already uses Gzip?

Usually yes, though the marginal gain is small. Whitespace removal also shrinks what you store — cache entries, database columns, and files on disk are not covered by transport compression.

How do I read compressed JSON again?

Run it through the JSON Formatter. Re-indenting is the exact inverse of compression, so nothing is lost by shipping the minified form.

Tools mentioned in this guide

Related JSON Topics & Reference Articles