Skip to content

Developer Tools

JSON Minifier

Removes indentation and line breaks for a compact JSON payload, good for reducing request size.

  • Free
  • No sign-up
  • Runs in your browser

Guide

What minifying JSON means

JSON is plain text, and a pretty-printed file spends many characters on indentation, spaces after colons and line breaks. Those characters make it readable but carry no meaning. Minifying means removing every bit of whitespace that is not inside a string, leaving the data on a single line.

The result represents exactly the same structure as the original. A parser will read both versions the same way. The only difference is size: the compact version is shorter, which is useful when JSON is sent over a network, stored in a field with a size limit, or embedded in another piece of text.

When a compact JSON payload is useful

Typical cases include putting a JSON blob into an environment variable or a single-line configuration setting, pasting a payload into a command-line argument, embedding data in an HTML attribute, or storing it in a database column. Some logging systems also expect one JSON object per line.

It can help with request size too, since fewer characters means fewer bytes to send, though the saving depends on how much indentation the original had and is often small once the server compresses responses. If you later need to read the data again, run it through the JSON Beautifier or the JSON Formatter to restore indentation.

How to minify JSON with this tool

  1. Paste your JSON into the box labeled Paste your JSON. A small example is already there.
  2. If the JSON is valid, a Minified box appears beneath it. Its label shows the size before and after, for example the original length followed by the new length, so you can see how much was saved.
  3. If the JSON is invalid, a red error message from the parser is shown instead, which tells you what went wrong.
  4. Click Copy to copy the minified text.

The work happens in your browser and nothing is uploaded. There is no download button and no options to set.

What to know before relying on it

This tool does not simply delete spaces. It parses the JSON and writes it back out, so the input must be strictly valid. Trailing commas, single quotes, comments and unquoted keys will produce an error. In a way that is helpful, because it doubles as a quick validity check.

Because the data is parsed into JavaScript values first, a few side effects can occur. Numbers too large or precise for a standard JavaScript number may lose precision. If an object repeats a key, only the last value is kept. Keys that look like whole numbers may be reordered ahead of other keys. If any of this matters, such as with large numeric IDs, keep those values as strings in your data.

Finally, the size shown counts characters, which equals bytes only for plain English text. Characters outside basic ASCII take more bytes when stored.

Frequently asked questions

Does minifying change my data?

The structure and values stay the same, with the caveats that very large or high-precision numbers can lose precision, duplicate keys collapse to the last one, and key order can shift for numeric-looking keys.

Why do I get an error for JSON that works in my code?

The tool follows strict JSON rules. JavaScript object syntax allows trailing commas, single quotes and unquoted keys, but JSON does not. Fix those and the minified version will appear.

Will it remove whitespace inside strings?

No. Spaces and escape sequences inside string values are kept exactly as they are. Only the formatting whitespace between values is removed.

Is my JSON sent anywhere?

No. Parsing and output happen entirely in your browser.