Home / Developer tools / JSON compressor

JSON Compressor

Make JSON as small as you need. Start with the safe level that only removes whitespace, and go further if you accept changes to the data.

Try:

The work is done in your browser. Your JSON is not sent to any server.

Three levels of compression

LevelWhat it doesChanges the data?
SafeRemoves all whitespace outside stringsNo
BalancedSafe, plus shorter number text: 1.50 becomes 1.5 and 1E+05 becomes 1e5No. The values are equal
MaximumBalanced, plus removing null values and empty strings, arrays and objects from objectsYes. Keys disappear

You can also tick each option yourself, and round decimals to a number of places. Rounding changes the data too.

What the data-changing options do

  • Remove null values. A key whose value is null is removed from its object. Items inside arrays are never removed, because that would shift the positions of the other items.
  • Remove empty values. Removes keys whose value is "", [] or {}. This works from the inside out, so an object that becomes empty is removed too.
  • Round decimals. Limits numbers that have a decimal point or exponent to a number of places, and drops trailing zeros. Useful for coordinates and prices with float noise such as 0.30000000000000004.

Use these only when the receiver treats a missing key and null alike. Many APIs do not: a missing key can mean keep the old value, while null can mean clear it.

How to compress JSON

  1. Paste the JSON or open a file.
  2. Choose a level. Safe never changes the data. Balanced shortens number text. Maximum removes empty data.
  3. Optionally set a size budget in KB, to see whether the result fits a limit such as a cookie or a payload cap.
  4. Check the bytes saved and the gzip size, then copy or download the result.

Which level should I use?

  • Safe for configuration, data you do not own, and anything you are unsure about.
  • Balanced for numbers written by a program, such as 1.50 or 1E+05.
  • Maximum only for data you control end to end, where you know that a missing key and a null value mean the same thing.

Typical size limits

WhereLimit
Browser cookieAbout 4 KB per cookie
URL2 KB is a safe limit for older systems
Amazon DynamoDB item400 KB
Local storageAbout 5 MB per origin in most browsers

Example: Maximum level

{"id": 7, "price": 19.50, "coupon": null, "notes": "", "tags": [], "stock": 1.0E+2}

becomes

{"id":7,"price":19.5,"stock":1.0e2}

Other ways to make JSON smaller

  • Return fewer fields. Let clients ask for only what they need, with a fields parameter or GraphQL.
  • Paginate. Send 50 records, not 5,000.
  • Send columns, not rows. For a table with many rows, one array per column avoids repeating every key in every row.
  • Shorten key names. Saves bytes but hurts readability and changes your format. Gzip already handles repeated keys well, so the gain is small.
  • Use a binary format such as MessagePack or CBOR when both sides support it.

Size budget and gzip

Enter a size budget in KB and the tool tells you whether the result fits. It also shows the gzip size, which is what a browser downloads when the server compresses responses. If you control the server, turn on gzip or Brotli first: it usually saves more than any change to the JSON text.

Compress or minify?

The Safe level is the same as the JSON minifier. This page adds the optional steps that remove data. For the full picture, including HTTP compression, read the JSON minification guide.

Your JSON is processed in your browser and is not uploaded. See also the JSON validator and the JSON formatter.

Frequently asked questions

How do I reduce the size of a JSON file?

Minify it first. Then, if the receiver allows it, remove null and empty values and round long decimals. Turn on gzip or Brotli on the server as well.

Is it safe to remove null values?

Only if the program that reads the JSON treats a missing key and null in the same way. Check before you use it.

Why did my number change?

You used the round decimals option, or a shortening such as 1.50 to 1.5. Shortening keeps the value, rounding does not.

Is JSON compression the same as gzip?

No. Compressing here makes the JSON text smaller and it stays JSON. Gzip turns the text into binary data that must be unpacked.

Does compressing JSON affect SEO?

Not directly. Smaller JSON loads faster, and page speed is part of user experience. Search engines read structured data the same way compressed or not.

What is the best way to reduce JSON size?

Send fewer fields, paginate, and turn on gzip or Brotli on the server. Then minify, and only remove data if the receiver allows it.