Home › JSON Minifier

JSON Minifier Online

Remove all whitespace from JSON to reduce file size for production. Free online JSON compressor — instant results, no signup.

Minify JSON Now →

Before and After Minification

Prettified (428 bytes):

{
  "user": {
    "id": 101,
    "name": "Alice Johnson",
    "email": "alice@example.com",
    "roles": [
      "admin",
      "editor"
    ],
    "active": true
  }
}

Minified (121 bytes — 72% smaller):

{"user":{"id":101,"name":"Alice Johnson","email":"alice@example.com","roles":["admin","editor"],"active":true}}

Why Minify JSON?

Use Case Benefit
API responsesReduces bandwidth, faster response times
localStorage / cookiesMore data fits within size limits (5MB for localStorage)
Embedded in HTML/JSSmaller page size, faster initial load
Mobile networks30-50% size reduction on slow connections
CDN / edge cachingLower storage costs at scale

Minify JSON in JavaScript

// Minify a pretty-printed JSON string
const minified = JSON.stringify(JSON.parse(prettyJson));

// Minify a JavaScript object
const minified = JSON.stringify(myObject); // no indent arg = minified

// Minify while removing specific keys (e.g. debug fields)
const minified = JSON.stringify(myObject, (key, value) => {
  if (key === '__debug' || key === '_internal') return undefined;
  return value;
});

Minify JSON from the Command Line

# Using Python (no install needed)
python3 -c "import json,sys; print(json.dumps(json.load(sys.stdin)))" < data.json

# Using jq
cat data.json | jq -c .

# Using Node.js
node -e "process.stdout.write(JSON.stringify(JSON.parse(require('fs').readFileSync('/dev/stdin','utf8'))))" < data.json

Minify JSON in Python

import json

with open('data.json') as f:
    data = json.load(f)

# Minified (no separators = most compact)
minified = json.dumps(data, separators=(',', ':'))

# Save to file
with open('data.min.json', 'w') as f:
    f.write(minified)

Frequently Asked Questions

What does JSON minification do?+
JSON minification removes all unnecessary whitespace (spaces, newlines, tabs) from a JSON document while keeping the data identical. The result is a single-line string with the same data but fewer bytes — faster to transfer over networks.
How much smaller does JSON get after minification?+
Typically 10–30% smaller for average JSON. Highly indented JSON with long keys can shrink 40–50%. Combined with gzip/brotli compression applied by HTTP servers, the bandwidth savings are consistent and meaningful at scale.
When should I minify JSON?+
Minify JSON in production API responses, file uploads, and stored data where readability is not needed. Keep JSON formatted for configuration files, debugging output, and version-controlled data files where human readability and diff quality matter.
Is minified JSON harder to read?+
Yes — it becomes a single line with no indentation. That's intentional for production use. Paste minified JSON into the JSON Formatter to expand it back to readable form whenever you need to inspect it.
Does minification change the data?+
No. Minification only removes whitespace outside of string values. All data, keys, values, nesting levels, and ordering are preserved exactly. Minified JSON round-trips back to identical parsed data.
What is the difference between JSON minifier and HTTP compression?+
A minifier removes whitespace from the JSON text itself. HTTP compression (gzip, brotli) further reduces bytes during network transfer and is transparent to the application. Best practice is to use both: minify JSON before sending, and let the server apply compression during transfer.

Minify your JSON now

Free, instant — your data never leaves your browser.

Open JSON Minifier →

Also useful: JSON Beautifier | JSON Formatter | JSON Validator | JSON to CSV | JSON Repair