My Tool Studio
Developer Tools·2 min read

Minify JSON: Shrink Payloads to a Single Line

Pretty-printed JSON is easy to read and wasteful to send. The JSON Minifier strips every space, tab and line break outside your strings and returns the same data on one line. Paste JSON or upload a .json file, press Minify, and the byte counts show what you saved. It all runs in your browser.

1.24 KB{"a": 1,"b": 2}MINIFIED · 430 B{"a":1,"b":2,"c":3,"d":4}−64%

What minifying JSON does

Same data, fewer bytes.

Minifying removes only the whitespace between tokens. Keys, values, order and any spaces inside strings stay the same. Numbers are copied character for character, so 1.0 stays 1.0 and a long ID keeps every digit. The one exception is the Sort keys option, which has to parse the data and so re-prints numbers the JavaScript way.

The line under the panes shows the input and output size in KB and exact bytes, plus the percentage saved. Deeply nested JSON with wide indents shrinks the most. JSON that was already compact changes little.

How to minify JSON

Three steps.

The input has to parse first, so broken JSON is reported instead of being half-minified.

  • Paste JSON into the JSON box, drop a file on it, press Upload .json or Load URL, or press Try sample.
  • Leave Output on Minified JSON, or switch to Escaped string or Beautified. Turn on Sort keys if you want A to Z order, then press Minify, or tick Minify as you type.
  • Press Copy, or Download to save a .min.json file (.txt for an escaped string).

Minify or stringify

A common mix-up.

Minified JSON is still an object or array. Stringifying goes a step further: it wraps the minified JSON in double quotes and escapes the quotes and backslashes inside. The Escaped string option does that. Use it when the JSON has to live inside another string, such as a field in a larger JSON document, an environment variable or a test.

The escaped version is a little larger than the minified one, because every inner double quote gains a backslash.

How much it really helps

Set realistic expectations.

The main gain is fewer bytes to store and send. Parsing is slightly faster too, but the difference is usually small. If your server already gzips responses, the saving over the network is smaller than the raw figure, because whitespace compresses well. Minifying still pays off for payloads you paste into configs, docs and request bodies.

When the minifier says your JSON is invalid

Fix it, then minify.

A trailing comma, a comment or single quotes stop the parse, and the problem line is highlighted with its column and a reason. JSON does not allow comments, but config files often have them. Tick Remove comments and trailing commas first, or press Clean and retry, and the minifier strips comments, trailing commas and single quotes before it minifies.

For a missing comma or bracket, fix the highlighted line by hand. The JSON Validator gives a fuller report if you need one.

Going back, and other languages

The reverse trip.

To read compact JSON again, switch Output to Beautified and press the button again, or paste it into the JSON Formatter for more indent choices and a tree view. The data is identical, so it expands back into indented lines.

JavaScript and CSS have their own tools. The JavaScript Minifier uses Terser to shrink scripts, the CSS Minifier handles stylesheets, and the JS Beautifier and CSS Beautifier make minified code readable again.

Try it now

Open JSON Minifier

The tool is one click away. No sign up, no upload, no payment.

Open JSON Minifier