JSON Minifier: Minify JSON to One Line

Strip every insignificant space, tab, and newline from JSON to get a single compact line — with bytes before and after, percentage saved, and a real gzip estimate. Everything runs in your browser.

Input JSON

Output

 

What minifying JSON does

JSON has two kinds of whitespace. Whitespace inside a string is data and is kept exactly. Whitespace between tokens — the newlines and indentation a formatter adds, the space after a colon or comma — is insignificant: the grammar in RFC 8259 allows any amount of it, or none. Minifying removes all of the second kind, so { "a": 1, "b": 2 } becomes {"a":1,"b":2}. Both parse to the identical value.

This tool does it by parsing the input with JSON.parse and re-serializing with JSON.stringify and no spacing argument. A side effect is normalization: duplicate structural whitespace, odd line endings, and a trailing newline all disappear, and invalid JSON is rejected with an error rather than passed through.

Why minify

Minifying is not obfuscation. Every key and value is still in plain sight; it only removes formatting.

JSON to one line: where a single line is required

Minified JSON is always one line, which is often the whole point rather than the byte saving:

If the destination needs the JSON inside quotes (a JSON string field, a shell or code string), use One line as escaped string. For a list of records that should be one per line (log ingestion, BigQuery, jq -c style), use Array to JSON Lines.

Worked example

{
  "name": "api",
  "ports": [ 80, 443 ],
  "tls": true
}

becomes {"name":"api","ports":[80,443],"tls":true}, and as an escaped string "{\"name\":\"api\",\"ports\":[80,443],\"tls\":true}".

What is kept and what is removed

RemovedKept
Indentation and leading spacesAll string contents, exactly
Line breaks between keysKey order
Space after : and ,Every value and its type
Trailing whitespace\n and \t escapes inside strings

How much you actually save

InputRaw bytesMinifiedGzip of minified
Pretty-printed, 2-space indent100%~55–80%~15–25%
Pretty-printed, 4-space / tabs100%~45–70%~15–25%
Already compact100%100%~20–30%

The important row is the last column. Indentation is extremely repetitive, so gzip and brotli — which almost every server and CDN apply automatically — compress it away to almost nothing. Minifying a document that will be sent gzipped typically saves only a low single-digit percentage on the wire. Where minifying still clearly wins is anywhere compression is not in play: uncompressed responses, data pasted into another file, and size limits measured in raw characters.

When not to minify

Leave a file indented if a human reads or edits it: package.json, tsconfig.json, .eslintrc.json, CI pipelines, fixtures checked into version control. A minified file produces a one-line diff for every change and is painful to review. Keep the readable copy as the source of truth and minify only at build or send time.

Questions

Does minifying change the data?

No. Whitespace between tokens carries no meaning, so the minified document parses to exactly the same value. The tool also normalizes the JSON and rejects anything invalid.

Is minification the same as obfuscation?

No. It only removes spaces, tabs, and newlines. Keys and values stay fully readable. It is a size optimization, nothing more.

How much does it save?

Removing 2-space indentation cuts roughly 20 to 50 percent of raw bytes, but once gzip is applied on the wire most of that would have compressed away, so the real transfer saving is often only a few percent.

Should I minify config files?

Usually not. Files edited by hand should stay indented for readable diffs and reviews. Minify machine-to-machine payloads and embedded data instead.

Can I expand minified JSON again?

Yes. Click Beautify (or paste it into the JSON formatter) to get indented JSON back. The round trip is lossless.

My input is JSON Lines. Will it join them?

No. JSON Lines is several values, and the minifier expects one. Wrap the records in [ ] with commas to make an array; to go the other way, use Array to JSON Lines.

Is my JSON uploaded?

No. Parsing, minifying, and the gzip estimate all run locally in your browser.