SmartQueryTools

JSON Minifier

Remove all whitespace from JSON to reduce file size. Paste or upload a JSON file — runs entirely in your browser.

Input

Minified output

How to use the JSON Minifier

  1. Paste JSON into the Input box, or click Upload JSON file and pick a .json file from your computer.
  2. The minified version appears in the output box as you type. There is no button to press.
  3. If the JSON is not valid, an error message shows the parser error and the output stays empty. Fix the input and the output updates.
  4. Check the size note above the boxes. It shows how much smaller the output is, and the input and output sizes in bytes as they would be saved in a UTF-8 file.
  5. Click Copy to put the result on your clipboard, or Download to save it as minified.json.

Worked example

A small user record, formatted with two-space indentation, is minified before being stored in a config value.

Input (137 bytes)

{
  "id": 42,
  "name": "Alice",
  "tags": ["admin", "ops"],
  "active": true,
  "address": {
    "city": "Oslo",
    "zip": "0150"
  }
}

Minified output (100 bytes)

{"id":42,"name":"Alice","tags":["admin","ops"],"active":true,"address":{"city":"Oslo","zip":"0150"}}

All whitespace outside of strings is removed. Text inside strings is kept as is, so "0150" keeps its leading zero because it is a string. The tool reports this result as 27% smaller, from 137 to 100 bytes.

When to minify JSON

Minify JSON when a machine is the only reader. Good cases are API responses, payloads stored in a database column, values in environment variables, and JSON bundled into a web page. Smaller files load faster and cost less to store and send.

Keep the formatted version when people need to read or edit the file. Config files in a code repository are a good example. Diffs of minified JSON are hard to review because the whole document sits on one line.

If your server already compresses responses with gzip or Brotli, minifying still helps, but the gain is smaller. Compression removes most repeated whitespace on its own.

Frequently Asked Questions

Does minifying JSON change the data?

No. Keys, values, arrays and nesting stay the same. Only the whitespace between tokens is removed, so any JSON parser reads the minified file as the same data.

How much smaller will my JSON get?

It depends on how much indentation the file has. Pretty-printed JSON with 2 or 4 space indents usually shrinks by 20% to 40%. JSON that is already on one line will not shrink at all. Sizes are counted in UTF-8 bytes, so accented letters, emoji and other non-ASCII text count as 2 to 4 bytes each, the same as on disk.

Why do I get an "Invalid JSON" error?

The input must be strict JSON. Common causes are trailing commas, single quotes around strings, unquoted keys, and comments. These are allowed in JavaScript but not in JSON. Remove them and try again.

Are there any cases where the output differs from the input?

Yes, a few. The tool parses the JSON and writes it back out. Numbers are normalised, so 1.50 becomes 1.5 and integers larger than 2^53 lose precision. Keys that look like whole numbers, such as "10", are moved before the other keys in the same object. If an object repeats a key, only the last value is kept.

Is my JSON uploaded anywhere?

No. The file is read and minified in your browser tab. Nothing is sent to a server.

Related tools