JSON Minifier
Minify JSON by removing whitespace and formatting for compact, production-ready output.
JSON Minifier tool
Example
Input: { / "a": 1, / "b": [1, 2] / } (pretty-printed over 4 lines)
Result: {"a":1,"b":[1,2]}
All whitespace outside strings is removed. Comments and trailing commas are stripped too, so JSONC-style input still minifies to valid JSON.
What the JSON Minifier Does
| Input | Output |
|---|---|
| { "a": 1, "b": [1, 2] } | {"a":1,"b":[1,2]} |
| {"a": 1, // note (then "b": 2} on the next line) | {"a":1,"b":2} |
| {"a": /* x */ 1} | {"a":1} |
| {"a": [1, 2,], } | {"a":[1,2]} |
| {"s": "keep // this"} | {"s":"keep // this"} |
| {"n": 1.0, "e": 1e3} | {"n":1,"e":1000} |
Output of this minifier. Text inside strings is never changed.
- Paste your formatted or pretty-printed JSON into the input text area.
- The minifier validates your JSON and instantly strips all unnecessary whitespace and line breaks, plus any comments and trailing commas.
- Review the compact, single-line JSON output in the Minified JSON panel.
- If the input is invalid, read the error message below the panels and fix the reported problem.
- Click the copy button to copy the minified JSON for use in API responses, storage, or embedded configs.
Why and How to Minify JSON
A JSON minifier removes every space, tab and line break that sits outside a string, giving the smallest valid JSON for the same data. { "a": 1, "b": [1, 2] } becomes {"a":1,"b":[1,2]}. This minifier is also forgiving about its input. Many config files, such as VS Code settings and tsconfig.json, use JSONC, which is JSON with // and /* */ comments and trailing commas. Strict JSON allows neither. If the input fails to parse, the tool strips comments and trailing commas outside strings and tries again. The output is always strict JSON that any parser accepts. Text inside strings, even something that looks like a comment, is never touched.
Because the data is parsed and rewritten, numbers come out in their shortest form: 1.0 becomes 1 and 1e3 becomes 1000. Whole numbers above 9,007,199,254,740,991 lose precision, since JavaScript stores all numbers as 64-bit floats. Very large IDs should be sent as strings for that reason. Minified JSON suits API payloads, values stored in a database or local storage, and JSON placed inside code or an environment variable. The panels also run in reverse: paste minified JSON into the right panel to get it pretty-printed with 2-space indentation. To explore large JSON as a tree, use the JSON Formatter.
Sources
Frequently Asked Questions
Related Tools
JSON Formatter and Validator
Format, validate, beautify, and minify JSON data with a collapsible tree view and line-and-column error detection.
Developer ToolsCSS Minifier
Minify CSS by removing whitespace, comments, and redundant code to reduce file size.
Developer ToolsJavaScript Minifier
Minify JavaScript by removing whitespace, line breaks, and comments for smaller files, without renaming your code.
Developer ToolsHTML Minifier
Minify HTML by removing comments and collapsing whitespace between tags and inside tags to reduce document size.
Developer Tools