JSON Minifier

Remove whitespace and line breaks from JSON, or beautify it back, right in your browser

Example
0 chars | 0 lines

What is a JSON Minifier?

A JSON minifier removes the indentation, line breaks, and spaces that make JSON easy for people to read but are not needed by programs. The data stays the same: the same keys, values, arrays, and nesting, written in the smallest valid form.

Minified JSON is the usual format for API responses, configuration shipped to browsers, and data stored in logs or databases, where every byte is sent or stored many times. This tool also includes Beautify, so you can switch back to an indented layout whenever you need to read or debug the data.

How to Use This JSON Minifier

  1. Paste your JSON into the input box, or click Example to load sample data.
  2. Choose an action: click Minify JSON to remove whitespace, or Beautify to indent it.
  3. Check the size comparison. Original, Minified, and Saved show how much smaller the result is.
  4. Fix any Parse Error. If the JSON is not valid, the tool shows an error instead of output. See the tips below for common causes.
  5. Copy Result or use Download .json.

Example: Before and After Minifying

This API-style response is indented with two spaces.

{
  "user": {
    "id": 1042,
    "name": "Ava Chen",
    "email": "ava@example.com",
    "roles": ["admin", "editor"],
    "profile": {
      "active": true,
      "lastLogin": null,
      "preferences": {
        "theme": "dark",
        "language": "en"
      }
    }
  },
  "meta": {
    "page": 1,
    "perPage": 25,
    "total": 134
  }
}

After minifying, the whole document fits on one line.

{"user":{"id":1042,"name":"Ava Chen","email":"ava@example.com","roles":["admin","editor"],"profile":{"active":true,"lastLogin":null,"preferences":{"theme":"dark","language":"en"}}},"meta":{"page":1,"perPage":25,"total":134}}
Metric Value
Original344 bytes
Minified224 bytes
Saved120 bytes (34.9%)

Savings depend on how much indentation the file has. Deeply nested, heavily indented JSON saves more, and JSON that is already compact saves almost nothing.

What Changes and What Stays the Same

This tool reads your JSON with the browser's built-in JSON.parse and writes it back with JSON.stringify, so the output follows JavaScript's rules. For most data you will never notice, but a few cases change:

In your input In the minified output Why
Spaces, indentation, line breaksRemovedThis is what minifying does
"price": 10.0"price":10Numbers are rewritten in their shortest form
"rate": 1e3"rate":1000Exponent notation becomes a plain number
"id": 12345678901234567890"id":12345678901234567000Integers above 9007199254740991 lose precision
"name": "a""name":"b"With duplicate keys, the last one wins
Keys "10" then "2""2" first, then "10"Keys that look like whole numbers are sorted first
"\u00e9""é"Unicode escapes are written as the character
"\/path""/path"Escaped slashes are written as plain slashes

Text inside string values is never touched, and spaces inside strings are kept exactly as written.

Here is a small input that shows these cases together.

{
  "price": 10.0,
  "rate": 1e3,
  "id": 12345678901234567890,
  "10": "ten",
  "2": "two",
  "name": "a",
  "name": "b"
}
{"2":"two","10":"ten","price":10,"rate":1000,"id":12345678901234567000,"name":"b"}

That input is 123 bytes and the output is 82 bytes. If a value must stay exact, such as an account number or a large ID, store it as a string instead of a number.

Minify vs Beautify

Minify JSON Beautify
GoalSmallest valid outputReadable output with indentation
ResultEverything on one lineOne item per line, indented by depth
Best forSending, storing, or embedding JSONReading, debugging, and reviewing changes
ReversibleRun Beautify to get an indented layout againRun Minify to compact it again

Beautify gives you a clean layout, not your original spacing, so keep a copy of the source if exact formatting matters.

Tips and Common Mistakes

  • JSON is stricter than a JavaScript object. Keys and strings need double quotes, trailing commas are not allowed, and comments are not allowed. Single quotes and unquoted keys cause a Parse Error.
  • Look near the error position. The Parse Error message usually points to where parsing stopped. The exact wording differs between browsers.
  • Keep the original. Minify the copy you send, not your only source file.
  • Store exact numbers as strings. IDs, phone numbers, and values above 9007199254740991 can change when parsed as numbers.
  • Do not rely on key order. The JSON specification treats objects as unordered, so a tool or language is allowed to reorder keys.
  • JSON Lines is not one JSON document. A file with one object per line gives a Parse Error. Minify one line at a time instead.
  • Add compression on top. Gzip or Brotli on your server shrinks minified JSON further.

Common Use Cases

  • API responses and mock data: smaller payloads that are easier to paste into tools and logs.
  • Configuration embedded in pages: compact JSON inside HTML attributes or script tags.
  • Database columns, cookies, and URL parameters: places with size limits.
  • Test fixtures and curl payloads: a one-line body is easier to pass on the command line.
  • Logs: one line per record.

Frequently Asked Questions

How do I minify JSON online?

Paste your JSON into the input box, click Minify JSON, then use Copy Result or Download .json. Original, Minified, and Saved show how much space you saved.

Will minifying JSON change my data?

The structure, keys, and values stay the same. A few edge cases change because of how JavaScript reads JSON: numbers are rewritten in their shortest form, very large integers lose precision, duplicate keys keep the last value, and keys that look like whole numbers move to the front. See the table above.

Why did my number change from 10.0 to 10?

JSON.parse reads 10.0 as the number 10, and JSON.stringify writes it back as 10. The value is the same. If you need to keep 10.0 exactly, store it as a string.

Why did my large number change?

JavaScript numbers are accurate only up to 9007199254740991. A larger integer such as 12345678901234567890 is rounded when it is parsed. Store large IDs as strings to keep every digit.

Can I turn minified JSON back into readable JSON?

Yes. Paste the minified JSON and click Beautify to get an indented, one-item-per-line layout. It restores a readable format, not your original spacing.

Why do I get a Parse Error?

The JSON is not valid. Common causes are a trailing comma, single quotes, an unquoted key, a comment, or a missing bracket. Fix the error near the position the message points to and run it again.

How much smaller will my JSON be?

It depends on the file. The example above saves 34.9%, and JSON that is already compact saves very little. Original, Minified, and Saved show the exact numbers for your input.

Is my JSON uploaded to a server?

No. Everything runs in your browser using the built-in JSON.parse and JSON.stringify, and your data never leaves your device.