Skip to content
JSON Tidy

JSON minify

Paste or open a JSON file to get it on one line with every unneeded space removed. You’ll see the size before and after. It runs in your browser, so nothing is uploaded.

JSON

Minified

What minifying changes

Only the whitespace between values: indentation, line breaks, and the spaces after commas and colons. Spaces inside strings are part of the data, so they stay.

Before

{
  "city": "Denver",
  "tags": ["api", "v2"],
  "note": "Keep  these  spaces"
}

After

{"city":"Denver","tags":["api","v2"],"note":"Keep  these  spaces"}

Everything else is left exactly as written. That matters more than it sounds: minifying with JSON.stringify(JSON.parse(text)) rewrites 1.50 as 1.5 and rounds IDs longer than 15 or 16 digits, so 12345678901234567890 becomes 12345678901234567000. This tool doesn’t parse and rebuild the numbers, so that can’t happen.

When it’s worth it

Minified JSON is handy when it has to fit on one line: an environment variable, a curl -d argument, a log entry, or a cell in a CSV file. It also trims files you store or bundle.

For API responses, the savings are smaller than the percentage suggests. Servers usually compress responses with gzip or Brotli, which already shrinks repeated spaces to almost nothing. Minify anyway if it’s free in your setup, but don’t expect a big speedup from it.

To make minified JSON readable again, paste it into the JSON formatter.

Minifying JSON in code

// JavaScript: no indent argument means no whitespace
JSON.stringify(data)

# Python: the default separators add a space after , and :
json.dumps(data, separators=(",", ":"))

# Command line
jq -c . data.json

These parse the JSON first, so the number rounding described above applies to the JavaScript version. Python keeps large integers exact, and jq 1.7 and later keeps large numbers exact as long as the filter doesn’t do arithmetic on them.

Files can be up to 2 MB. If the JSON has an error, the tool shows the line, and the JSON repair page can fix the common ones.