How the JSON Minifier works
The minifier first checks the input with a strict JSON parser, so invalid JSON is reported with its line and column instead of producing broken output. It then writes the document back out with no spaces, tabs or line breaks between tokens.
Only whitespace outside strings is removed. Each number and string is copied from your input exactly as written, so
large integers keep all their digits, 1.50 stays 1.50, and escape sequences inside strings
are not changed. The size panel compares the UTF-8 byte size of the input and the output and shows the bytes saved
and the percentage reduction.
How to use the JSON Minifier
- Paste your JSON into the input box, open a .json file, or select Load example.
- Select Minify JSON, or press Ctrl + Enter (Cmd + Enter on a Mac).
- Check the size panel for the original size, the minified size, the bytes saved and the percentage reduction.
- Copy the minified JSON or download it as a .json file. If the input is invalid, the error message shows the line and column.
Example
This formatted input (38 bytes):
{
"id": 1042,
"tags": ["a", "b"]
}
is minified to (28 bytes):
{"id":1042,"tags":["a","b"]}
The size panel shows 10 bytes saved, a 26.3% reduction.
Common use cases
- Reducing the size of JSON files served by a website or bundled with an app.
- Putting JSON on a single line for an environment variable, a command-line argument or a log entry.
- Shrinking test fixtures or sample payloads before embedding them in source code.
- Estimating how much whitespace contributes to the size of an API response.
Common errors and how to fix them
- The minified output is barely smaller than the input
- Minifying only removes whitespace between tokens. If the input was already compact, nearly all of its size is real data. Enabling gzip or Brotli compression on your server reduces the transferred size far more than minifying does.
- Minifying fails with a syntax error
- The minifier validates before it minifies, so broken input is rejected rather than silently mangled. Fix the reported line and column, or repair relaxed JSON with the JSON Beautifier first.
- The minified JSON breaks when pasted into a config file or command line
- Minifying does not escape anything for a destination format. Double quotes still need escaping for your shell or config syntax, and JSON placed in a query string must be encoded with the URL Encoder.
Frequently asked questions
Does minifying change my data?
No. Only whitespace between tokens is removed. Strings, including any spaces and escape sequences inside them, and numbers are copied exactly as written, and key order is kept. Large integers keep every digit.
How is the size saving calculated?
The tool counts the UTF-8 bytes of your input and of the minified output. Bytes saved is the difference, and the reduction is that difference as a percentage of the original size.
What if my JSON is invalid?
Minifying stops and the error message shows the line, column and reason, and the cursor jumps to the problem. Invalid JSON is never partly minified.
Can it minify JSON with comments?
No. Comments are not valid JSON, so they are reported as an error. Use the JSON Beautifier to remove comments and repair the JSON first, then minify the result.
Is my JSON uploaded to your server?
No. Minifying runs in your browser, and the JSON you paste or open is not sent to our server.