About the JSON Minifier
Make JSON as small as possible for APIs, config values and storage. The data is validated first, so invalid JSON is never silently changed.
Formatted JSON is pleasant to read but spends a lot of space on spaces and line breaks. When JSON goes into an environment variable, a database field, a URL, a request body or local storage, every byte counts and single-line JSON is often required. This minifier compresses JSON safely: it parses the data first, so invalid JSON is reported rather than silently changed.
Only whitespace outside strings is removed, so values stay exactly the same. You can sort keys alphabetically for consistent output, and escape the result as a JSON string when you need to embed JSON inside another JSON value or a code literal. The size saving is shown.
Minifying is the opposite of formatting. Both operations keep the data identical, so you can switch between a compact version for machines and a readable version for people as often as you like, using this tool and the JSON Formatter side by side.
How to use the JSON Minifier
- 1Paste your JSON.
- 2Click Minify.
- 3Copy the one-line result and see the size saved.
Key features
- Validates before minifying.
- Removes whitespace outside strings.
- Optional key sorting.
- Escape as a JSON string.
- Shows size saved.
Practical uses
- Storing JSON in an environment variable.
- Embedding JSON in HTML data attributes.
- Reducing payload size in API tests.
- Creating compact fixtures.
- Pasting configuration into a single-line field in a hosting dashboard.
Example
A 1.2 KB pretty-printed config with 2-space indentation typically shrinks by a quarter or more when minified, with identical data.
Tips and common mistakes
- Keep a formatted copy for editing.
- Use the escape option when JSON must sit inside a string.
- Combine with gzip on servers for large payloads.
- If minifying fails, open the same text in the JSON Formatter to see the error position clearly.
Limitations
- JSON with comments must be cleaned first.
- It does not shorten key names.
Privacy
JSON is processed locally.
Frequently asked questions
Is minified JSON still valid?
Yes. Only spaces and line breaks outside strings are removed.
Can I sort the keys?
Yes, tick "Sort keys" to order object keys alphabetically.
What is the opposite of minify?
Use the JSON Formatter to make it readable again.
Why escape JSON as a string?
Some systems store JSON inside another JSON field or a code string, which needs quotes and backslashes escaped.
Does minifying change numbers like 1.0?
The JSON is parsed and re-written, so 1.0 becomes 1 and 1e3 becomes 1000. The values are mathematically the same.
Is there a size limit?
No fixed limit. Files of several megabytes minify quickly in modern browsers.