OnlineTextLab
Esc

JSON Minifier

One compact line of JSON, with the savings shown and every value left as you wrote it.

Minified JSON

One compact line appears here, with the bytes saved.

Runs on your device. Your files and text are not uploaded.

About JSON Minifier

Whitespace makes JSON readable and adds bytes that a machine never looks at. Minifying removes it, which helps when a value has to fit in an environment variable, a single log line, a query parameter, a fixture or a request body you are pasting into a terminal.

You get one line, and a status line such as 166 B to 126 B, 24% smaller. Malformed input is rejected with its line and column, so you never get a compact copy of something that was already broken.

How it works

Only the spaces, tabs and line breaks between tokens are removed. The text is read by the same strict parser the other JSON tools here use, then written back with no separators beyond commas and colons. Whitespace inside strings is part of your data and stays.

Nothing is reinterpreted along the way. A value of 1.50 is not shortened to 1.5, \u00e9 is not turned into an accented letter, and key order is unchanged. That means the output decodes to exactly what the input does, and a hash of it only differs because the spacing differs.

How to use JSON Minifier

  1. Paste into the JSON to minify box, or press Upload. Try an example shows it on a small config.
  2. The compact result appears straight away, with the size before and after underneath.
  3. Press Copy, or Download to save minified.json.

A small config, compacted

Input
{
  "name": "api-gateway",
  "version": "2.4.1",
  "price": 1.50,
  "routes": [
    { "path": "/users", "auth": true },
    { "path": "/health", "auth": false }
  ]
}
Output
{"name":"api-gateway","version":"2.4.1","price":1.50,"routes":[{"path":"/users","auth":true},{"path":"/health","auth":false}]}

The input is 166 bytes and the output 126. Look at price: it is still 1.50, because the number is carried over as text.

When it helps

  • Putting a JSON config into a single environment variable or secret
  • Fitting a test payload on one line of a shell command
  • Reducing a fixture committed to a repository, when nobody needs to read it
  • Writing a JSON Lines file, where each record has to be on its own single line

Tips for a better result

  • Do not count on minifying alone to speed up an API. Compression such as gzip or Brotli removes most of the same repetition, so the gain over the network is usually far smaller than the figure shown here.
  • Keep the formatted original in version control and generate the minified copy. One-line files make diffs unreadable.
  • If the result is going into a URL, run it through URL Encode Decode next, since braces and quotes are not safe there.

Good to know

  • It only removes whitespace. It does not shorten keys, drop nulls or change number formats, so savings depend on how much indenting the file had.
  • Comments and trailing commas are errors here, so JSONC files need those removed first.
  • The result is a single line, which editors can struggle with once it reaches many megabytes.
  • A file over 5 MB is refused by Upload, though pasting one still works.

Questions people ask

Is minified JSON still valid JSON?

Yes. Whitespace between tokens is optional in the standard, so any parser reads the two forms identically.

Does it change spaces inside my strings?

No. Only whitespace outside strings is removed. A value like "New York" keeps both of its spaces.

How much smaller will my file get?

It depends on the indenting. Deeply nested data formatted with 4 spaces shrinks a lot, and a file that is already mostly one line barely changes. The status line reports the real figure for your input.

Can I reverse it?

Yes, and no information is lost. The JSON Formatter gives you the indented version back, though any custom alignment you had is not recovered.

What to use next

Last reviewed . Read our editorial policy.