JSON Minifier

Minify JSON by removing spaces and line breaks, with validation. Shows the parser error for invalid JSON. Free, runs in your browser.

Input
Result

About JSON Minifier

The JSON Minifier strips out spaces and line breaks to make JSON as small as possible, for requests, embedding in code or one-line test fixtures. It checks that the JSON is valid first.

Spaces inside strings are kept

Only the white space between items is removed; text inside values stays exactly as written.

Numbers are normalised

1.0 becomes 1 and 1E3 becomes 1000. Very long integers lose precision, so keep long IDs as strings.

Key order is kept

Keys stay in their original order.

Clear errors

Invalid JSON, such as a trailing comma, shows the exact position.

How much smaller?

It depends on the indentation of the original. Heavily indented files shrink a lot. To read it again, use the JSON Formatter.

Private

Everything runs in your browser. Your code and data are not uploaded.

Example

{ "name": "Ana", "age": 30 } becomes {"name":"Ana","age":30}.

Minify or gzip?

Web servers usually compress responses with gzip or Brotli, which removes much of the saving anyway. Minifying still helps for stored data and size limits.

How to use JSON Minifier

  1. Paste your JSON or open a file.
  2. Check that no error appears.
  3. Copy the minified result or download it.
  4. Use the JSON Formatter to make it readable again.

Related guide: How to Format and Validate JSON (With Common Errors Explained)

Help & FAQ

What does the JSON Minifier do?

It validates JSON and writes it without extra spaces, tabs and line breaks.

Does it change spaces inside strings?

No. In the test the string "keep spaces" kept both spaces. Only white space between tokens is removed.

Why did 1.0 become 1?

The JSON is parsed and written again, so numbers are written in their shortest form: 1.0 becomes 1 and 1E3 becomes 1000.

Why did a long number change?

Very large integers lose precision when parsed, so 12345678901234567890 became 12345678901234567000. Store such values as strings.

Does it keep the key order?

In the tests keys stayed in their original order.

Does it accept comments?

No. JSON has no comments, and a line starting with // was refused as an unexpected token.

What does an invalid file show?

It shows Invalid JSON with the browser's message and position and gives no result.

Where is the error in our JSON?

When the browser reports a position, the message gives it with the line and column, for example line 1 column 8. Look just before that point for a missing quote, comma or bracket.

Does minifying make our site faster?

Slightly for payloads with a lot of indentation. Server compression such as gzip saves far more.

Can we undo the minification?

Yes. Paste the result into the JSON Formatter to indent it again, though your original indent style is not restored.

Can it open files?

Yes. Use the Open .txt file button or paste the text.

Is our JSON uploaded?

No. The text is processed in your browser.

More in Developer Tools

See all 39 in Developer Tools