JSON minifier
Minify JSON by removing all spaces, indentation and line breaks outside strings. Validates the input first and shows the output length. Runs in your browser.
About JSON minifier
The JSON minifier removes every space, tab and line break that is not part of a string value, producing the most compact form of your data on a single line. Paste formatted JSON or open a file and the minified version appears immediately, with its character count in the status bar.
Because the input is parsed before it is rewritten, the minifier never produces broken output: invalid JSON is reported as an error instead. Use it to shrink fixtures and payloads, fit JSON into an environment variable or a single database field, or remove whitespace differences before comparing two documents.
How to use JSON minifier
- Paste formatted JSON into the input box, or open or drop a .json file.
- Keep the Minify option selected; it is chosen by default on this page.
- Check the character count in the status bar to see the size of the result.
- Copy the single-line output or download it as a .json file.
Features
- Removes all whitespace outside strings; spaces inside string values are kept exactly.
- Validates the input with a strict JSON parser and reports errors instead of guessing.
- Outputs one line with no trailing newline.
- Shows the character count of the minified output.
- Expands the same input again with the 2 spaces, 4 spaces or Tabs options.
Common uses
- Storing JSON in an environment variable, a CSV cell or a command-line argument.
- Reducing the size of static JSON files served to a browser or app.
- Pasting a payload into a chat, ticket or form field that strips line breaks.
- Removing whitespace differences so two JSON documents can be compared as text.
Tips
- If your server already compresses responses with gzip or Brotli, minifying saves less transfer size than the raw difference suggests. It matters most where the text itself is stored or counted, such as environment variables and database fields.
Frequently asked questions
Does minifying JSON change the data?
No. Only insignificant whitespace is removed, so any parser reads the same values. Two parsing side effects apply: if an object repeats a key, only the last value is kept, and integers larger than 2^53 may be rounded. Escape sequences such as \u00e9 are written as the character itself.
How much smaller does minified JSON get?
It depends on how the input was formatted. Deeply nested JSON indented with 4 spaces or tabs can shrink substantially, while JSON that was already compact barely changes. Compare the character count in the status bar with the size of your original file.
Is minified JSON still valid JSON?
Yes. Whitespace between tokens is optional in JSON, so a single-line document is just as valid as an indented one and parses to the same result in every standard JSON library.
Does the minifier remove comments?
The input must already be strict JSON, which has no comment syntax. If it contains // or /* */ comments, it is reported as invalid rather than cleaned up. Remove the comments first; JSON-with-comments and JSON5 files are not accepted.
How do I un-minify JSON?
Select 2 spaces, 4 spaces or Tabs on this page to expand the same input again, or use the JSON formatter. Only whitespace is added back; the values and key order stay as they were.
Is my input uploaded?
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.
Your privacy comes first
Tools run in your browser. Files, text and results are not uploaded to our servers and are cleared when you leave the tool.