About the JSON Minifier tool
Pretty-printed JSON is great for reading, but indentation and line breaks can make up a large part of a file. When JSON is sent over an API, stored in a database column, embedded in HTML or placed in an environment variable, a compact single-line version saves space and avoids problems with line breaks.
This JSON minifier first parses your input with the browser’s own JSON parser, so it doubles as a validator: if there is a missing comma, a trailing comma or an unquoted key, you get the error with its line and column instead of broken output. Valid JSON is then written back out with no whitespace at all. Strings are escaped correctly, numbers are kept as JavaScript represents them and Unicode text stays readable.
An optional “Sort keys A–Z” switch orders object keys alphabetically at every level, which produces a canonical form that is handy for comparing documents or building cache keys. The size panel shows the original bytes, minified bytes, percentage saved and gzipped sizes. Your data never leaves the browser.
How to use JSON Minifier
- Paste JSON into “JSON input”, open a .json file, or click “Load sample”.
- Fix any error shown with its line and column number.
- Turn on “Sort keys A–Z” if you want a canonical, alphabetically ordered result.
- Copy the “Minified JSON” output or download it as a .min.json file.
Features
Validates while minifying
Invalid JSON is reported with the exact line and column instead of producing broken output.
Canonical key sorting
Optional alphabetical key order at every nesting level for stable, comparable output.
Correct escaping
Strings are re-serialised with proper JSON escapes, never by blind text replacement.
Size and gzip stats
Original, minified and gzipped sizes show exactly what you saved.
When to use it
- Compact a JSON payload before storing it in a database text column.
- Put a JSON config on one line for an environment variable or CLI argument.
- Reduce the size of a JSON fixture committed to a repository.
- Create a canonical sorted form of JSON for hashing or comparison.
Frequently asked questions
Does minifying JSON change the data?
No. Only whitespace between tokens is removed. Keys, values and array order stay the same unless you choose to sort keys.
Why does my JSON show an error?
Common causes are trailing commas, single quotes, comments or unquoted keys, which are allowed in JavaScript but not in JSON. The error message shows where the parser stopped.
Are very large numbers preserved?
Numbers are parsed as JavaScript numbers, so integers above 9,007,199,254,740,991 can lose precision. Keep such IDs as strings in your JSON.
How do I make minified JSON readable again?
Paste it into the JSON Formatter on this site, which re-indents it with 2 or 4 spaces or tabs.