Skip to content

JSON Minifier

Minify JSON to a single line for a request body, an environment variable or a log. Numbers and key order stay as written.

Input · JSON

Valid JSON

Strict RFC 8259 syntax

Size
194 B
Lines
12
Depth
4
Keys
8
Objects
3
Arrays
1
Strings
4
Numbers
3
Booleans
0
Nulls
0
Valid JSON3 top-level keys · depth 4 · 8 keysRuns in your browser

Load from a URL

Your browser fetches it directly, so the server must allow cross-origin requests (CORS).

How to minify JSON

  1. Paste JSON or press Open file.
  2. Press Minify or Ctrl + Enter.

What it removes

Every space, tab and line break between keys, values and brackets. Strings keep their inner spaces, numbers their exact digits, and keys their order. For sorted keys on one line, press Sort keys, then Minify.

Escape sequences come out in their shortest form: \u00e9 becomes é and \/ becomes /, while \" and \t stay. The parsed strings are the same.

Example

A webhook payload, pretty printed (319 bytes, 14 lines):

{
  "event": "checkout.completed",
  "id": "evt_8KD2",
  "created": "2026-11-04T18:22:05Z",
  "data": {
    "cart_id": "c_5521",
    "total": 86.40,
    "currency": "EUR",
    "items": [
      { "sku": "BAG-07", "qty": 1, "note": "gift wrap, no receipt" },
      { "sku": "SOCK-3P", "qty": 2, "note": null }
    ]
  }
}

Minified, 242 bytes (24% smaller):

{"event":"checkout.completed","id":"evt_8KD2","created":"2026-11-04T18:22:05Z","data":{"cart_id":"c_5521","total":86.40,"currency":"EUR","items":[{"sku":"BAG-07","qty":1,"note":"gift wrap, no receipt"},{"sku":"SOCK-3P","qty":2,"note":null}]}}

Minify or gzip

Compression narrows the gap: with Node.js defaults, the example is 233 bytes pretty and 207 minified under gzip, or 205 against 166 under Brotli. Minifying still pays off where nothing is compressed: environment variables, query strings, local storage, and logs with one record per line.

Minified is not canonical. Key order and number spelling stay as written, so two systems can minify the same data to different bytes. For hashing or signing, use RFC 8785, the JSON Canonicalization Scheme.

To embed the result in another JSON string, use JSON escape. To indent it again, use JSON pretty print.

Minify JSON in code

  • JavaScript: JSON.stringify(JSON.parse(text))
  • Python: json.dumps(data, separators=(",", ":")). The default separators add a space after each comma and colon.

Both parse the numbers first, so 86.40 comes out as 86.4.

When it fails

Minify needs valid JSON; the Report tab shows the line and column of the first error. Comments, common in files like tsconfig.json, can be stripped with JSON repair. The JSON validator explains other errors.

Questions

What is the difference between minifying and compressing?

Minified JSON is still plain text that any parser can read. Gzip or Brotli compression produces binary data that has to be decompressed first. You can do both.

Can I minify several JSON documents at once?

One at a time. The minifier expects a single JSON value, so documents pasted one after another stop with an error after the first.

Can I minify XML too?

Yes, with the XML minifier. It also removes comments unless you switch on Keep comments.

Related tools

Esc