JSON Minifier

Paste JSON and get it on one line with every space and line break outside strings removed, or switch back to a 2-space layout.

How to use

  1. Paste your JSON into the Input box; the minified Output appears as you type.
  2. Press Pretty print to lay it out again with 2-space indentation, or Minify to put it back on one line.
  3. If the JSON is invalid, read the reason and the line and column shown instead of the output, and fix that spot.
  4. Press Copy to copy the result, or Clear to start over.

Examples

InputOutput
{ "id": 1024, "tags": ["sale", "new"], "note": "meet at the New York office" }{"id":1024,"tags":["sale","new"],"note":"meet at the New York office"}
{"order":{"id":"A-17","items":[3,5]},"paid":false}{ "order": { "id": "A-17", "items": [ 3, 5 ] }, "paid": false }
{ "retries": 3, }
Trailing comma: remove the comma after the last item (line 3, column 1)

About this tool

What minifying removes

Outside strings, JSON only allows whitespace (spaces, tabs, line breaks and carriage returns) around { } [ ] : ,, where it carries no meaning. Minifying deletes exactly that whitespace. Anything inside quotes is data, so the space in "New York" stays. Numbers are copied as written, so 12345678901234567890 does not get rounded the way JavaScript's JSON.parse would round it, and 1.50 stays 1.50. Escapes such as \n or \t and duplicate keys are left as they are.

The sample loaded above is 397 bytes as shown and 300 bytes minified: about a quarter of it is indentation and line breaks.

When it helps

  • One-line places. Environment variables, a <script type="application/json"> block, a CLI argument or a single line in a log or CSV cell all want JSON without line breaks.
  • Uncompressed payloads. Message queues, local storage or embedded devices that store raw bytes save the whole whitespace share.
  • Fixtures and diffs. A minified copy compares byte for byte with what an API returns.

When it barely matters

If the response is already served with gzip or Brotli, most of the gain disappears. Indentation is the same few spaces repeated on every line, and compressors are built to replace repeated runs with short back-references. So the compressed size of pretty and minified JSON ends up much closer than the raw sizes suggest. Check the transferred size in your browser's network panel before adding a minify step to a build.

Comments are not JSON

JSON (RFC 8259) has no comments, so // and /* */ are reported as errors here rather than silently dropped. Files such as tsconfig.json or VS Code settings use JSONC, which allows them; strip the comments with JSONC-aware tooling first. Trailing commas and single quotes are refused for the same reason.

Privacy

Minifying runs in your browser. Nothing you paste is uploaded, so API responses with tokens or customer data stay on your device.

Frequently asked questions

Does minifying JSON change the data?

No. Only whitespace outside strings is removed. Strings, numbers, escapes, key order and duplicate keys are kept exactly as written.

Will big numbers lose precision?

No. Numbers are copied character for character, so an ID like 12345678901234567890 stays exact instead of being rounded to the nearest double.

Is minifying worth it if my server uses gzip?

Usually only a little. Gzip and Brotli already compress the repeated indentation well, so the transferred sizes of pretty and minified JSON end up close.

Why does it say my JSON has a comment error?

Standard JSON does not allow // or /* */ comments. Remove them, or use a JSONC tool for files like tsconfig.json that permit them.

Is my JSON sent to a server?

No. Everything happens in your browser and nothing you paste leaves your device.