JSON Minifier
Minify JSON by removing whitespace and line breaks, with a byte-size comparison before and after. Paste formatted JSON, get a compact payload. Nothing is uploaded.
Worked examples
- Indented config object
The typical case: a formatted config file is stripped of whitespace before shipping it in a request body or a build artifact.
- Deeply nested array of records
Nested arrays of objects carry the most formatting whitespace, so this is where minifying saves the most payload size.
- Already-compact JSON
Confirms the tool is a no-op on input that is already minified — useful for verifying a build pipeline didn't accidentally re-expand output.
What this tool does
Minifying JSON removes every character that exists only for human readability — indentation, line breaks, and spaces around punctuation — without changing the data. This tool parses your JSON first, so the result is guaranteed to still be valid and semantically identical, and it reports exactly how many bytes you saved.
When you need it
- Shipping a JSON payload in a request body, a URL query parameter, or an environment variable, where every byte counts and whitespace has no value.
- Storing JSON in a database column or a config value with a size limit.
- Embedding a JSON blob inside another file (a script tag, a
.envfile, a CI variable) where extra line breaks would need escaping anyway. - Checking whether a build step accidentally re-expanded a file that should have shipped minified.
Rules the minifier applies
- The JSON is parsed, not just stripped of spaces with a regex. Whitespace inside string values (like
"line one\nline two") is left untouched because it's part of the data, not formatting — a naive find-and-replace would corrupt it. - Key order and structure are preserved. Minifying doesn't sort or reorganize anything. The one JavaScript quirk: object keys that are whole numbers (
"1","2") are always written first, in ascending order. - Numbers are re-serialized in their normalized JavaScript form.
1.0becomes1,1e3becomes1000, and an integer beyond about 9 × 10^15 is rounded to the nearest value a double can hold — this only matters if your consumer cares about the literal digit sequence rather than the numeric value. If the same key appears twice in one object, only the last occurrence survives. - Invalid JSON is rejected up front, with the same parser error you'd get from the formatter, so you never end up minifying broken JSON into differently broken JSON.
Reading the size numbers
The size figures count bytes of the text as pasted, so a trailing newline in your input counts toward the original size. Both the original and minified byte counts are measured in UTF-8 bytes, not character counts — a string with accented letters or emoji takes more bytes than characters, which is what actually matters for a network payload or storage limit. The reduction percentage is (original − minified) ÷ original, so a heavily indented, deeply nested file with lots of array-of-object structure will show a bigger saving than a flat object with few keys, because indentation scales with nesting depth.
Things to check after minifying
- If the output needs to be embedded inside another JSON string (double-encoded), you'll need to JSON-stringify it again separately — this tool minifies, it doesn't escape.
- Minifying is not compression: repeated substrings aren't deduplicated the way gzip would. For large payloads sent over HTTP, gzip or Brotli at the transport layer will save far more than minifying JSON does — use both together, not one instead of the other.
- If your downstream system parses JSON with a strict 64-bit integer library, re-check large numeric IDs after minifying, since the value is re-serialized through JavaScript's number type either way.
Limits
Input is capped at 2 MB. The tool minifies the whole document in memory, so extremely large files may be slow to paste into a browser textarea even though minification itself is fast.
Frequently asked questions
- Is my JSON uploaded anywhere?
- No. Minifying runs entirely in your browser; nothing is sent to a server.
- Does minifying change the data?
- Only whitespace and line breaks are removed, but numbers are re-serialised (1.0 becomes 1, and integers beyond 2^53 are rounded) and a repeated key keeps only its last value. Strings and key order are untouched, except that whole-number keys are listed first.
- How is the size reduction calculated?
- Both the original and minified text are measured in UTF-8 bytes, and the reduction is (original − minified) ÷ original.
- Can I minify invalid JSON?
- No — the tool parses the input first, so invalid JSON is rejected with an error instead of being minified as plain text.