JSON Minifier — Minify JSON Online

Remove all unnecessary whitespace from JSON, validate it at the same time and see exactly how many bytes you save — before and after gzip.

Runs in your browserUpdated
Open file

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the JSON Minifier

  1. Paste JSON or open a .json file.
  2. The JSON is validated and minified instantly; errors show the line and column.
  3. Optionally sort keys alphabetically or write each array item on its own line (NDJSON).
  4. Copy or download the minified JSON.

What is JSON minification?

Minifying JSON removes every space, tab and line break that is not inside a string. The data is unchanged — JSON.parse returns exactly the same object — but the text is smaller. Pretty-printed JSON with two-space indentation is often 20–40 % larger than its minified form.

{
  "id": 42,
  "tags": ["a", "b"]
}

becomes {"id":42,"tags":["a","b"]}.

When to minify JSON

  • API responses and config shipped to browsers — fewer bytes over the network.
  • Storing JSON in databases, Redis, cookies, environment variables or query strings where size limits apply.
  • Embedding JSON-LD or app state in HTML.

For files you edit by hand, keep the formatted version in your repository and minify during the build. Use the JSON formatter to turn minified JSON back into readable form.

Minified vs gzipped size

Gzip and Brotli are very good at compressing repeated whitespace, so after HTTP compression the difference between formatted and minified JSON shrinks to a few percent. The stats show both numbers so you can judge whether minifying is worth it for your case. For big payloads, removing unused fields and shortening repeated keys saves far more.

Sort keys and JSON Lines

OptionUse it for
Sort keysStable output for diffs, caching keys and signatures — two objects with the same data produce identical text
JSON LinesLog files, BigQuery and Elasticsearch bulk imports, streaming — one JSON value per line

Validation

Because the JSON is parsed before it is minified, the tool doubles as a validator: trailing commas, single quotes, comments and unquoted keys are reported with their position. Large numbers keep JavaScript’s precision limits — integers above 253 may lose digits.

Tools that pair well with the JSON Minifier

  • JavaScript Minifier — Paste JavaScript and get production-ready minified code from Terser — the same engine used by Vite, webpack and Rollup — with real before/after and gzipped sizes.
  • JSON to CSV — Turn a JSON array into a spreadsheet-ready CSV.
  • XML Minifier — Compact XML documents, feeds, sitemaps and SOAP payloads by removing indentation and comments — with a well-formedness check so nothing breaks.
  • Website Compression Test — Enter a URL to see which compression your server sends for each Accept-Encoding, how many bytes it saves, whether its CSS and JavaScript are compressed, and what Brotli could save.

Frequently asked questions

Does minifying JSON change the data?
No. Only whitespace outside strings is removed. Parsing the minified JSON gives exactly the same values.
How do I convert JSON to one line?
Paste it here — the minified output is a single line. Copy it or download it as a file.
Why is the gzipped size so close for formatted and minified JSON?
Gzip and Brotli compress repeated whitespace extremely well. Minifying still helps when data is not compressed, for example in databases, cookies or URLs.
Is my JSON uploaded?
No. Validation and minification run in your browser.

Related tools