JSON Minifier
Paste JSON and get a compact single line instantly. Keeps every value, shows the real UTF-8 bytes and gzipped size, and can minify JSONC config files that have comments and trailing commas.
- Free, no account
- No watermark
- No usage limit
About the JSON Minifier
Paste JSON here and get it back as one tight line, every value intact, ready to ship. This JSON Minifier strips the whitespace your editor added for reading and leaves the smallest legal JSON that still parses. Two things pull it ahead of the usual free minifier. It shows the real UTF-8 byte count before and after, plus the gzipped size that actually travels once your server compresses the response. And with one toggle it will minify config files that carry comments and trailing commas, the JSONC that a strict minifier flatly rejects. Everything runs in your browser, so nothing you paste is uploaded, logged, or saved.
The case that sends most people looking for a better tool is a config file. You copy a tsconfig.json or a VS Code settings file into a plain minifier and it dies on the very first comment. This one has a JSONC mode that strips those comments and trailing commas for you, then hands back valid minified JSON. If you paste something that looks like JSONC while the toggle is off, it even offers a one click switch right there in the error.
How to use
- Get your JSON in. Paste it, drop a
.jsonfile onto the box, or hit Upload file. It reads whatever shape it's in, pretty-printed with two-space indent, tabbed, or already half compact. - Read the minified output. It appears the moment your JSON is valid, a single line with the extra whitespace gone. There's no button to press, it updates live as you type.
- Check the size row. You get the original size, the minified size, the percent saved, and the gzipped size of the result, all in real UTF-8 bytes.
- Flip on JSONC mode if you need it. For a config file with comments or trailing commas, tick Allow comments, trailing commas and other loose JSON. The tool removes them and minifies what's left.
- Copy or download. Put the compact JSON on your clipboard, or save it as a
.jsonfile for a request, a config value, or wherever it's headed. - Fix errors if they show up. Invalid JSON gets a red message naming the problem and the spot the parser gave up on. Correct that character and the output comes back on its own.
Minify config files that have comments (JSONC)
Most basic minifiers get this wrong, because plenty of real config files aren't strict JSON at all. tsconfig.json, .babelrc, VS Code's settings.json, and many linter configs are written in JSONC or JSON5, supersets that let you drop a // note above a setting or leave a trailing comma after the last item. Those are exactly the files people want to compact before pasting into a build config or an environment value.
A strict JSON.parse throws the instant it hits //, and most free minifiers do nothing more than call that parser. So you get an unhelpful error and no output. With JSONC mode on, this tool cleans up the comments and trailing commas first, then minifies the result to strict, valid JSON that any parser will accept.
The comments get stripped out, because a comment was never part of the JSON data model. If you need a note kept inside the file, put it in a real key like "_comment" and it survives as data. The tolerant parser rewrites a few other things on the way through, single quotes into double, unquoted keys into quoted ones, a bare NaN into the string "NaN". The tool prints what it actually did to your file right under the output, so you are never left guessing which of those applied.
It will not guess at a missing ending though, and that's the part I'd want to know about. Hand most tolerant parsers a file that got cut off, a bracket left open or a string that never closes, and they invent the rest and give you back something that looks finished. Same with a hole where a value belongs, like "b": }, which usually gets quietly filled in with null. This one refuses and tells you which line the file stops on. Minifying a config that came through a bad copy and shipping it three settings short is a rough afternoon.
Real byte numbers, and where gzip fits
Most tools that show a size count characters, which is misleading, because a character isn't a byte. A £, an é, or an emoji is one character but two to four bytes on the wire, so this tool measures actual UTF-8 bytes, the same bytes your network and database count.
If your server gzips responses, and most do, the raw percent saved overstates the win. Gzip is good at squeezing repeated spaces, so a lot of what minifying removes, gzip would have crushed anyway. That's why the size row also shows the gzipped size of the minified output, so you see roughly what a compressed response actually weighs.
Minifying still helps even behind gzip, for reasons that have nothing to do with HTTP:
- JSON living in a database column, a cookie, an in-memory cache, or a message queue is usually not compressed. There, nothing compresses it later, so the minified size is what you store.
- Cookies are capped near 4 KB each in every browser, so trimming whitespace can be the difference between fitting and getting truncated.
- The receiving parser reads every byte before your app can use the data. Fewer bytes means a little less parsing, which matters most on a low-powered phone.
Minify first to drop the obvious waste, then let gzip or Brotli compress what's left.
What gets stripped, and what never changes
Minifying does not touch your data, and not one value moves. What disappears is only the stuff that was never data:
- The indentation, the leading spaces on every nested line.
- Newlines between keys, array items, and braces.
- The space after each colon (
"a": 1becomes"a":1) and after each comma. - Trailing whitespace and blank lines.
Your keys keep their exact names. Strings keep every character inside the quotes, so "hello world" stays "hello world", because that space is real data. Numbers, booleans, and null come through byte for byte, and nested structures keep their order.
A few behaviors are worth knowing. Duplicate keys in one object collapse to the last value, which is how every JSON parser behaves rather than a choice this tool makes. Numbers can normalize, so 1.0 may come back as 1, with the value identical, keep a huge integer as a string if its exact text matters. And Unicode stays as itself rather than turning into a \uXXXX escape.
How this pairs with the JSON formatter
Minifying and pretty-printing are lossless round trips of each other, so there's no risk in bouncing between them, compact to send or store, expand to read and debug. If you want the readable direction, our JSON Formatter re-indents minified JSON into a properly nested layout.
For anything automated you don't need a web tool at all. Code that generates JSON already emits compact output (JSON.stringify(value), or json.dumps(value, separators=(',', ':')) in Python), and jq -c collapses files in bulk. Reach for this tool when you have a chunk of JSON on your clipboard and want it small, checked, and copied back in seconds without it leaving your machine.
Frequently asked questions
Will turning on JSONC mode change my data?
Mostly it only changes how a value is spelled, and it names every change it made under the output. Two cases go further than that. NaN and Infinity are not JSON values at all, so they come back as the strings "NaN" and "Infinity" rather than numbers. And two separate JSON documents pasted in one go get merged into a single array, which is often exactly what you want out of an .ndjson log, but you should see it said out loud before you ship it.
Why show a gzipped size instead of just bytes saved?
Because the uncompressed saving and the real network saving are different numbers. The percent is measured on the raw text, but a compressed response is much smaller, since gzip already handles most of the whitespace minifying removes. The gzipped figure gives a truer sense of what a payload weighs once your server compresses it.
Which files count as JSONC or JSON5?
tsconfig.json, .babelrc, VS Code's settings.json, and many linter configs. JSONC adds // and /* */ comments to JSON. JSON5 goes further with trailing commas, single quotes, and unquoted keys. This tool reads strict JSON by default and switches to the tolerant path only when you enable the toggle.
My JSON says it's invalid. What usually causes that?
The common ones: single quotes where JSON wants double quotes, a trailing comma in strict mode, a // or /* */ comment, or bare words like NaN and Infinity. The message points to where parsing stopped, and if the culprit is comments or trailing commas, the tool offers a one click switch to the tolerant mode.
Is my JSON uploaded or stored anywhere?
No. Parsing, minifying, validating, and counting bytes all happen locally in your browser. Nothing is sent to a server, saved, or logged, and closing the tab clears it. That makes it safe for internal API responses, tokens, or any config with secrets.
Can I minify a large file without pasting it?
Yes. Drop a .json file onto the input box or use Upload file, and it loads straight in without pasting a few thousand lines by hand. The file still never leaves your browser.
How do I get the readable, indented version back?
Open the same JSON in our JSON Formatter, which re-indents it into a nested layout you can scan and diff. The round trip changes nothing but whitespace, so you can compact for shipping and expand for reading as often as you need.