Skip to content

JSON Minifier

Minify JSON by removing whitespace and formatting for compact, production-ready output.

JSON Minifier tool

Loading...

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

InputOutput
{ "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.

  1. Paste your formatted or pretty-printed JSON into the input text area.
  2. The minifier validates your JSON and instantly strips all unnecessary whitespace and line breaks, plus any comments and trailing commas.
  3. Review the compact, single-line JSON output in the Minified JSON panel.
  4. If the input is invalid, read the error message below the panels and fix the reported problem.
  5. 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

No. Keys, values, types and order stay the same, and only the whitespace between them goes. The one thing to know is number formatting: 1.0 is written as 1 and 1e3 as 1000, which are the same values. Integers larger than 9,007,199,254,740,991 can be rounded, so keep big IDs in strings.
Yes. If strict parsing fails, the tool removes // line comments, /* block */ comments and commas placed just before a closing } or ], then parses again. The result is strict JSON. If the input still fails after that, you see the original error so you can fix the real problem.
It depends on how it was formatted. Deeply nested JSON indented with spaces shrinks the most, because indentation grows with every level. JSON that is already compact barely changes. If your server compresses responses with gzip or Brotli, the saving after compression is smaller, but the parsed size in memory is still reduced.
Yes. Paste it into the Minified JSON panel and the other panel shows it pretty-printed with 2-space indentation. For a folding tree view and error locations as well, use the JSON Formatter and Validator.

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 Tools

CSS Minifier

Minify CSS by removing whitespace, comments, and redundant code to reduce file size.

Developer Tools

JavaScript Minifier

Minify JavaScript by removing whitespace, line breaks, and comments for smaller files, without renaming your code.

Developer Tools

HTML Minifier

Minify HTML by removing comments and collapsing whitespace between tags and inside tags to reduce document size.

Developer Tools

JSON to CSV Converter

Convert a JSON array of objects to CSV with automatic column headers, and convert CSV back to JSON in the same tool.

Developer Tools

JSON to YAML Converter

Convert JSON documents to YAML format with syntax validation, clean formatting, and instant preview.

Developer Tools