Smaller JSON, same data
JSON Minifier
Paste formatted JSON or open a .json file to compress it into a single line. The minifier removes indentation and line breaks, keeps spaces inside strings, and shows exactly how many bytes you saved. All in your browser.
Tip: Ctrl + Enter runs Minify JSON
Valid JSON
144 B12 linesdepth 2Processed in your browser
What is JSON minification?
JSON minification removes whitespace that only exists for humans: indentation, line breaks and spaces between tokens. The result is a single line that parsers read exactly the same way, but with fewer bytes to store or send. Minifying JSON with 2-space indentation typically cuts its size by 20 to 30%, for example 22% on a real package-lock.json, and the saving grows with deeper nesting.
This minifier parses the JSON before writing it back on one line, so it never produces broken output and never touches the text inside strings. If the input is invalid, it tells you where and why instead of guessing.
How to minify JSON
- 1
Add JSON
Paste formatted JSON into the editor or press Open file to load a .json file.
- 2
Minify
Press Minify JSON. The editor now contains a single line, and the status shows the size before and after.
- 3
Copy or download
Copy the compact JSON or download it as a .min.json file.
- 4
Need it readable again?
Press Format to expand it back to indented JSON at any time.
Before and after
The space inside "hello world" is kept because it is part of the value. Only whitespace between tokens is removed.
| Version | Text | Size |
|---|---|---|
| Formatted (2 spaces) | {↵ "message": "hello world",↵ "count": 2↵} | 44 bytes |
| Minified | {"message":"hello world","count":2} | 35 bytes |
When to minify JSON
- API payloads
- Smaller request and response bodies, especially for mobile clients and high-volume endpoints.
- Environment variables
- Many platforms need JSON config on a single line, for example service account keys or feature flag sets.
- Embedding in code
- Paste one-line JSON into a string literal, HTML data attribute or SQL statement without breaking it.
- Storage
- Save space in databases, localStorage, caches and log lines that store JSON documents.
Minification vs gzip and Brotli
Minification and compression work well together but are different things. Minified JSON is still plain JSON that any parser can read. Gzip and Brotli encode bytes for transfer and must be decompressed first. Web servers usually apply them automatically, and minifying first still saves a little more and reduces parsing work.
| Minification | Gzip / Brotli | |
|---|---|---|
| Output | Valid JSON text | Binary encoded data |
| Readable without tools | Yes | No |
| Typical saving on formatted JSON | 20 to 30% | 70 to 90% |
| Where it happens | Build step or this tool | Web server or CDN |
Minify JSON in code
| Tool | Command |
|---|---|
| jq | jq -c . data.json |
| Python | python -c "import json,sys; print(json.dumps(json.load(sys.stdin), separators=(',', ':')))" < data.json |
| JavaScript | JSON.stringify(value) |
JSON Minifier FAQ
Does minifying JSON remove spaces inside strings?
No. Only whitespace between tokens is removed. Text inside strings, including spaces and escaped line breaks, stays exactly as it was.
Is minified JSON still valid JSON?
Yes. It is the same data with less whitespace, and every JSON parser reads it the same way.
How much smaller will my JSON be?
It depends on the indentation and nesting. Pretty-printed JSON usually shrinks by 20 to 30%. The tool shows the exact before and after size each time you minify.
Can I minify JSON with comments or trailing commas?
No. The input must be valid JSON. The validator shows where the comment or trailing comma is so you can remove it first.
Can I un-minify JSON?
Yes. Press Format to expand minified JSON back into readable, indented text.
Is minification the same as compression?
Not quite. Minification removes whitespace and keeps JSON readable by any parser. Compression such as gzip encodes the bytes and needs decompressing. Most servers do both.