Skip to content

JSON Minifier — Strip Whitespace and Compress JSON Online

Free

Minify JSON by removing all unnecessary whitespace. Reduces API response size by 20–40%. Validates before minifying. Free, browser-based, no upload.

json minifiercompress jsonjson compress online
All Developer Tools

Settings guide

Options:

  • ·Remove whitespace only (default) — Strips spaces, tabs, and newlines between tokens. Guaranteed-valid output parseable by any compliant JSON parser. No data is modified.
  • ·Sort keys alphabetically — Sorts object keys in addition to stripping whitespace. Use for deterministic output when hashing or diffing two JSON documents. Note: JSON spec makes no guarantee on key order, so only use this when consumers ignore insertion order.

How much will it reduce my JSON?

The reduction depends on how much whitespace is in your formatted JSON:

  • ·2-space indented, shallow nesting: ~20–25% reduction
  • ·4-space indented, deep nesting: ~35–45% reduction
  • ·Already compact JSON: minimal or no reduction

Format comparison

Minification vs gzip compression: HTTP gzip compression (applied at the transport layer) reduces JSON by 60–80% regardless of whitespace. If your server already sends gzip responses, JSON minification gives a smaller additional benefit. Minification still helps for in-memory size after decompression, and for environments where gzip is unavailable (some CDN edge functions, certain mobile contexts).

Minified JSON vs shorter key names: Minification removes whitespace only — it cannot shorten key names the way a JavaScript minifier shortens variable names. If you need to reduce JSON size beyond whitespace, the next step is redesigning the schema: shorter keys, numeric codes instead of enum strings, or a binary format like MessagePack.

How it works

1

Validate first

The input is parsed as JSON before minification begins. If any syntax error exists, it is reported and minification does not proceed — minifying invalid JSON produces invalid compact JSON.

2

Calculate savings

Original byte size is measured and projected output size is shown so you can see the exact reduction before copying.

3

Strip whitespace

All insignificant whitespace — spaces between tokens, indentation characters, and newlines — is removed. Whitespace inside string values is preserved exactly.

4

Copy to target

The output is a single-line JSON document. Paste it into your API response handler, JavaScript bundle, database field, or config file. It reformats identically when passed through any JSON formatter.

About this format

Pretty-printed JSON with 4-space indentation is 20–40% larger than its minified equivalent. For JSON served in API responses, bundled into JavaScript builds, or stored at high volume in a database, that overhead compounds. Minification strips every non-significant space, tab, and newline — producing the smallest valid JSON representation of the same data.

A 100KB formatted API response typically minifies to 60–80KB. Across thousands of daily requests, that is meaningful bandwidth and latency reduction without changing a single data value.

The minifier validates syntax before processing. If the input JSON is invalid, the error is reported first — minifying broken JSON produces broken minified JSON.

Frequently asked questions

Is minified JSON still valid JSON?+
Yes. Whitespace between tokens is optional in the JSON specification. A minified JSON document is syntactically identical to its formatted version — both produce the same data structure when parsed. Any compliant JSON parser handles both.
Does minification change any of my data?+
No. Only insignificant whitespace between tokens is removed. String values — including strings that contain spaces, tabs, or newlines — are not modified. Numbers, booleans, nulls, and structure are all preserved exactly.
Can minification break my JSON?+
Not if the input is valid JSON. If the minifier reports a syntax error, fix the input first. Minifying already-invalid JSON produces invalid compact JSON — garbage in, garbage out.
Should I store minified or formatted JSON in a database?+
Store formatted JSON when humans read or edit it directly (CMS content, application config). Store minified JSON for machine-consumed data where storage or read performance matters. Most production databases (PostgreSQL jsonb, MySQL JSON) store and index JSON internally regardless of formatting.
How is this different from what a JavaScript bundler does?+
JavaScript bundlers (esbuild, Terser) can both minify JSON and rename variable names to single characters in the surrounding JavaScript. This tool minifies only the JSON content itself — key names are preserved exactly because consuming code depends on them.

Related tools and guides