Skip to content
koducathome

JSON Minifier

Strip insignificant whitespace from JSON and see exactly how many bytes you saved.

How to use this tool

Steps for using the JSON Minifier.

  1. Paste formatted JSON into the Input JSON editor, or click Sample.
  2. Click Minify. The input is validated first; invalid JSON is reported with its line and column and nothing is changed.
  3. Read the size summary: original size, minified size and how much was saved, measured in UTF-8 bytes.
  4. Use Copy to put the single-line result on your clipboard, or Download to save it as minified.json.

Example

Minify a small object

Formatted JSON (37 bytes)
{
  "name": "Ada",
  "tags": [1, 2]
}
Minified JSON (27 bytes, 27% smaller)
{"name":"Ada","tags":[1,2]}

Common use cases

  • Putting a JSON config into an environment variable or a single-line .env value.
  • Embedding fixtures or seed data in source code, SQL inserts or shell scripts.
  • Reducing payload size for message queues, caches or database columns where compression is not applied.
  • Measuring how much of a stored document is whitespace before deciding whether to minify it at write time.

How JSON minification works

JSON allows any amount of space, tab, carriage return and line feed between tokens, and none of it carries meaning. Minifying removes that insignificant whitespace so the whole document fits on one line. Whitespace inside string values is part of the data and is always preserved.

This minifier validates the input with a strict RFC 8259 parser and then removes whitespace from the original text rather than re-serialising the parsed value. The difference matters: a parse-and-stringify round trip in JavaScript turns 1.0 into 1, 1e2 into 100, rounds integers above 2^53 such as 64-bit IDs, rewrites escapes like \u00e9, and drops duplicate keys. Working on the text means every value reaches the next parser exactly as you wrote it.

Savings depend entirely on how the document was formatted: deeply nested documents and wide indentation contain more whitespace, so they shrink more, while already-compact JSON barely changes. Sizes are reported in UTF-8 bytes, which is what is sent over the network or stored on disk, so a character like ü counts as two bytes.

If you serve JSON over HTTP, gzip or Brotli compression already removes most of the cost of whitespace, so minifying matters most where compression is not applied: environment variables, query strings, database columns, message queues, embedded fixtures and copy-paste into single-line fields.

Limitations

  • Only whitespace is removed — keys are not shortened and values are not rewritten.
  • Invalid JSON is not minified; fix the reported error first (the JSON Validator explains it in detail).
  • Input is limited to 2 million characters.

Frequently asked questions

Can minifying change my data?

No. The output contains exactly the same tokens as the input, in the same order, with only the whitespace between them removed. Numbers, string escapes and even duplicate keys are left untouched.

How do I turn minified JSON back into readable JSON?

Paste it into the JSON Formatter and click Format to pretty-print it with your choice of indentation.

Is minified JSON still valid JSON?

Yes. Whitespace between tokens is optional in the JSON grammar, so any parser that accepts the original accepts the minified version.

Why is the saving 0%?

The input was already minified — there was no whitespace outside strings to remove.

Should I minify JSON API responses?

Most frameworks already send compact JSON, and HTTP compression (gzip or Brotli) removes most of the remaining cost. Minification helps more for stored data and anything that travels without compression.