JSON Minify
Strip whitespace from JSON and see exactly how many bytes you saved
JSON
Minified
JSON Minify
Strip whitespace from JSON and see exactly how many bytes you saved
Features
- One-call minification via JSON.parse + JSON.stringify — round-trips through a real parser, so syntactically invalid input fails fast with the exact JavaScript engine error message
- Byte-accurate size statistics: TextEncoder.encode().length measures UTF-8 bytes (not character count), so multi-byte characters and emoji are weighed correctly
- Savings line shows absolute byte delta and percent of input size — matches what a gzip-pre-minified payload will look like on the wire
- Copy button toggles to Copied! for 1.5 s after click, giving a clear confirmation that the clipboard write succeeded — no silent failures
- Download button emits a `minified.json` Blob using application/json MIME, ready to drop into an HTTP request body or commit to a fixtures folder
- Parse errors surface with the JS engine's full message (line/column when the parser provides it) so you can pinpoint the offending character rather than guessing
- Pure client-side: input never leaves the browser, no telemetry, no upload. The minify call is synchronous and instantaneous for typical configs (sub-megabyte JSON)
- Output preserves key order and exact numeric representation — JSON.stringify doesn't re-encode integers as floats or change Unicode escapes, so the minified output is byte-equivalent to whatever a strict consumer would re-parse
How to use
- Paste your JSON into the input pane on the left.
- Click Minify. The tool runs JSON.parse to validate, then JSON.stringify with no indent argument to remove all insignificant whitespace.
- Read the stats row: input bytes, output bytes, and bytes/percent saved — useful for deciding whether the minification is worth the readability trade-off.
- Click Copy to put the minified string on your clipboard, or Download to save it as `minified.json`.
- If the input was invalid, a red error row will show the JS engine's parse message — fix the JSON and click Minify again.
Tips & Best Practices
- If you minify mainly to fit a bundle budget, also enable gzip in your CI's static-asset pipeline — gzipped pretty JSON is often smaller than unminified-but-uncompressed minified.
- Keep the original pretty-printed JSON in source control; minify in a build step rather than committing the minified version.
- For very large JSON (10 MB+) the TextEncoder pass is still fast, but the JSON.parse + JSON.stringify pair will spike memory briefly — fine in a browser tab, problematic in a hot-path service worker.
- If your JSON contains numbers near JS's safe-integer limit (2^53), be aware that JSON.parse converts them to doubles — minify won't change that, but it's worth knowing before you debug a precision mismatch.
- Use Download to drop the minified file into a fixtures directory; pair with JSON Diff later if you need to confirm the round-trip preserved everything.
FAQ
How much smaller will my JSON get?
Depends entirely on how much whitespace was there to start. A heavily pretty-printed config (2-space indent, key alignment, trailing newlines) often shrinks 30–50%. A JSON that's already on one line shrinks 0%. The stats row reports the exact number — try it on your data before committing to the minified version.
Should I minify JSON in production?
Usually no, because gzip / brotli compression already crushes repeated whitespace down to a handful of bytes. Minification helps when (1) you can't enable compression on the transport (some embedded targets), (2) you're embedding the JSON into a JS bundle where every byte counts against the bundle budget, or (3) you're optimising IndexedDB / localStorage where there's no transport compression.
Does this change my data in any way?
No. JSON.parse + JSON.stringify is a round-trip through the JavaScript JSON spec, which is a strict subset of ECMAScript. Numbers, strings, booleans, null, arrays, and objects all come out byte-equivalent to a valid re-parse. The only difference is whitespace and key ordering (JSON.stringify keeps the original insertion order of an object literal).
How are bytes counted?
Via TextEncoder().encode().length, which gives the UTF-8 byte length. Plain ASCII is one byte per character; é is two bytes; most CJK characters are three; most emoji are four. Counting JavaScript string length (code units) would over-report ASCII and under-report supplementary-plane characters; TextEncoder gives you the number that matches what hits the wire.
Why does Minify fail on my input?
JSON.parse is strict: no trailing commas, no comments, no single quotes around strings, no unquoted keys. If you're working with relaxed JSON (JSON5, JSONC) the parser will throw — preprocess with a relaxed parser first, or use the JSON Formatter tool's JSONC mode to clean it up. The error row shows the engine's message, often including the line/column that broke.
Is anything sent to a server?
No. Both panes stay in your browser; minification runs synchronously in the same JavaScript context that rendered the page. DevTools Network shows no requests when you click Minify. The page works offline after first load.
Will minified JSON still be diff-friendly?
Less so. A pretty-printed JSON file diffs line by line and reviewers can see exactly which key changed. A minified JSON file is one giant line — a single character edit shows up as a whole-line replacement in `git diff`. Keep source files pretty-printed; minify only for transport or storage.
How is this different from JSON Formatter?
JSON Formatter has a Minify button next to Pretty-Print plus tree view, JSONPath, JSONC, schema validation, and diff. This tool is the single-purpose lightweight version: paste, minify, copy, download — no panels, no modes, just bytes saved.