Skip to content

JSON Minifier

Minified JSON —
Original size (bytes)
—
Minified size (bytes)
—
Bytes removed
—
Size reduction
—

Paste a JSON document and the minifier parses it, then writes it back out with no whitespace between tokens. Spaces inside strings are kept. For example, { "a": 1, "b": [1, 2] } becomes {"a":1,"b":[1,2]}, shrinking from 23 to 17 bytes, a 26.1% reduction. Invalid JSON is reported instead of being guessed at.

About this tool

Pretty-printed JSON is easy to read in a diff but wasteful in a request body, an environment variable or a config value pasted into a single-line field. This minifier parses your input with the same strict grammar browsers use, so a trailing comma or a single-quoted key is caught rather than passed along. It then re-serialises the data compactly and reports the UTF-8 size before and after, plus the bytes removed. Because the output is rebuilt from parsed values, a few representations can change: 1.50 becomes 1.5, and integers beyond 2^53 lose precision. Everything runs locally in the page; the document is never uploaded.

How to use it

  1. Add your JSON

    Paste it into the box or open a .json or .txt file from your device.

  2. Fix any syntax error

    If parsing fails, the message under the box names the problem, such as an unexpected token.

  3. Copy the result

    Copy the single-line output and check the byte sizes and percentage removed.

Examples

A small object with spaces

JSON to minify
{ "a": 1, "b": [1, 2] }

Result Minified JSON: {"a":1,"b":[1,2]}
Original size (bytes): 23
Minified size (bytes): 17
Bytes removed: 6
Size reduction: 26.1%

  1. Parsed 23 bytes of input as JSON (RFC 8259).
  2. Re-serialised without spaces, tabs or line breaks outside strings: 17 bytes.
  3. Saved 6 bytes = 6 ÷ 23 × 100 = 26.1%.

Six spaces after colons and commas go, taking 23 bytes down to 17, a 26.1% cut.

Two-space indented document

JSON to minify
{ "name": "Ada", "tags": [ "math", "engines" ] }

Result Minified JSON: {"name":"Ada","tags":["math","engines"]}
Original size (bytes): 62
Minified size (bytes): 40
Bytes removed: 22
Size reduction: 35.5%

  1. Parsed 62 bytes of input as JSON (RFC 8259).
  2. Re-serialised without spaces, tabs or line breaks outside strings: 40 bytes.
  3. Saved 22 bytes = 22 ÷ 62 × 100 = 35.5%.

Line breaks and indentation are removed, leaving 40 bytes on a single line.

Spaces inside a string

JSON to minify
[ "hello world" , 3 ]

Result Minified JSON: ["hello world",3]
Original size (bytes): 21
Minified size (bytes): 17
Bytes removed: 4
Size reduction: 19%

  1. Parsed 21 bytes of input as JSON (RFC 8259).
  2. Re-serialised without spaces, tabs or line breaks outside strings: 17 bytes.
  3. Saved 4 bytes = 4 ÷ 21 × 100 = 19%.

Only whitespace between tokens is dropped; the space in "hello world" is part of the value and stays.

How it is calculated

minified = JSON.stringify(JSON.parse(input)); reduction = (original bytes − minified bytes) ÷ original bytes × 100

original bytes
UTF-8 length of the text you pasted
minified bytes
UTF-8 length of the compact output

RFC 8259 treats spaces, tabs, carriage returns and line feeds between tokens as insignificant. Parsing the text and serialising it with no indent removes all of them while leaving string contents untouched. Sizes are counted in UTF-8 bytes, the encoding JSON must use on the wire, so an accented letter counts as two bytes and an emoji as four.

When not to use it

  • Do not use it on JSON with integers larger than 9007199254740991, since those are rounded during parsing.
  • JSON with comments (JSONC) or trailing commas is rejected; strip those first or use a JSON5 tool.
  • If an exact byte-for-byte copy of number formats like 1.0 or 1e3 matters, a whitespace-only stripper is safer.

Common mistakes

  • Expecting duplicate keys to survive: only the last value for a repeated key is kept.
  • Pasting a JavaScript object literal with unquoted keys, which is not valid JSON.
  • Judging network savings from minification alone when the server already applies gzip or Brotli.

Frequently asked questions

Does minifying change my data?

The values stay the same, but some spellings can change: 1.50 is written as 1.5, 1e3 as 1000, and an escaped \u00e9 as é. Key order is preserved. Integers above 2^53 lose precision, because parsing stores numbers as double-precision floats.

Are spaces inside string values removed?

No. Only whitespace between tokens is removed. A string such as "hello world" keeps its space, and line breaks inside strings remain as \n escapes.

Why is the reduction smaller than I expected?

Compact JSON that already uses short indentation has little whitespace to lose, often 10 to 30 percent. Deeply nested documents with four-space indentation shrink more, sometimes by half.

Is minified JSON still worth it with gzip?

Gzip and Brotli compress repeated whitespace very well, so the transfer saving after compression is usually small. Minifying still helps where compression is absent, such as storage limits, query strings or single-line config values.

Why was my JSON rejected?

The parser follows RFC 8259 strictly. Trailing commas, single quotes, comments, unquoted keys and values such as NaN or undefined are all invalid JSON and produce an error naming the problem.

Is the JSON sent to a server?

No. Parsing and serialising happen in your browser, and a file you open is read locally without being uploaded.

Cite this tool

Using this tool in an assignment, article or report? Copy a citation, or a link for your website.

APA

Tools Directory Editorial Team. (2026, October 28). JSON Minifier. Tools Directory. Retrieved October 28, 2026, from https://tools.milunir.com/developer-tools/json-tools/json-minifier/

MLA

Tools Directory Editorial Team. “JSON Minifier.” Tools Directory, 28 Oct. 2026, https://tools.milunir.com/developer-tools/json-tools/json-minifier/. Accessed 28 Oct. 2026.

Chicago

Tools Directory Editorial Team. “JSON Minifier.” Tools Directory. Last modified October 28, 2026. Accessed October 28, 2026. https://tools.milunir.com/developer-tools/json-tools/json-minifier/.

Link<a href="https://tools.milunir.com/developer-tools/json-tools/json-minifier/">JSON Minifier – Tools Directory</a>