JSON Minifier

Minify JSON — strip every bit of insignificant whitespace down to one compact line — right in your browser. It truly parses the JSON, so invalid input is caught.

Developer Tools Free No upload Instant

Loading JSON Minifier…

Your browser is preparing the tool. It runs 100% locally.

Quick Answer

Paste JSON and the tool removes every space, tab and line break that is not inside a string, collapsing the data to one compact line. Unlike a regex tidier, it genuinely parses the JSON first, so the output is guaranteed valid and any malformed input is rejected with an error. It is the quick way to shrink a config or an API payload for transfer. Everything runs in your browser; nothing is uploaded.

What the JSON Minifier Does

This tool takes formatted, indented JSON and compresses it into the smallest equivalent text: a single line with no insignificant whitespace. The data is identical — only the spacing used to make it readable is removed.

It is the quick way to prepare JSON for somewhere size matters: an API request body, a config embedded in code, a cache value, or a query parameter, where indentation is wasted bytes.

How It Works

The tool parses your text into a real data structure and then serialises it straight back out with no spacer between keys, values and elements. Because it round-trips through an actual parse, the result is always valid JSON, and any whitespace that was only there for readability simply does not get written back.

That parse step is the important difference from a regex stripper. The tool understands strings, so spaces inside a string value are preserved, while the spacing between structural tokens is dropped. If the input is not valid JSON, the parse fails and the tool reports the error rather than producing broken output.

Processing pipeline

  1. Parse the JSON. Read the text into a real data structure, which also checks that it is valid JSON.
  2. Serialise with no spacing. Write the structure back out with no spaces between keys, values or array elements.
  3. Preserve string contents. Spaces inside string values are kept; only insignificant whitespace is removed.
  4. Return one line. Output the compact single-line JSON, ready to copy.

What minifying removes

parse the text into data, then serialise with no spacer • drop spaces, tabs and newlines between tokens • keep all whitespace inside string values • invalid JSON is rejected, not guessed
Worked example
Before: { "id": 7, "tags": [ "pdf", "image" ] } After: {"id":7,"tags":["pdf","image"]}

The data is unchanged — only readability whitespace is removed. Because it parses, a comment, a trailing comma or a single-quoted key (none of which are valid JSON) makes it report an error instead of minifying.

Privacy

Your JSON never leaves your device. It is parsed and minified in your browser with no network request, so nothing is uploaded.

Because the work is local, you can safely minify payloads or configs that contain tokens, keys or internal data without them being stored or sent anywhere.

Nothing persists between sessions — close the tab and the input and output are gone.

Standards & references

  • JSON (RFC 8259 / ECMA-404) — The strict JSON grammar. Whitespace between tokens is insignificant and can be removed; the tool relies on a real parser that enforces this grammar.
  • Valid JSON only — Comments, trailing commas, single-quoted strings and unquoted keys are not valid JSON. Because the tool parses, any of these is rejected rather than passed through.
  • Number precision — JSON numbers are read as standard double-precision floats, so integers beyond about 9 quadrillion (2 to the 53rd) can lose precision on the round trip — a property of JSON parsing everywhere, not this tool alone.

Accuracy & Limitations

Because it parses and re-serialises, the output is always valid JSON representing exactly the same data — there is no risk of it producing broken output from valid input, unlike a regex-based stripper.

Validity is enforced, so anything that is not strict JSON is rejected. JSON with comments or trailing commas (sometimes called JSONC or JSON5) will not minify here; remove those first or use a tool that supports them.

Very large integers can shift. Numbers beyond the safe integer range are stored as floating point, so a 20-digit identifier may come back rounded. Keep such values as strings if exactness matters.

Duplicate keys collapse to the last one, because the parser builds an object where each key appears once. That matches how JSON parsers behave generally, but it means a minified object can have fewer keys than the text you pasted.

Real-World Use Cases

Shrinking an API payload

Compress a request or response body to save bytes over the wire.

Embedding JSON in code

Inline a compact config without multi-line indentation.

Cache and storage values

Store JSON compactly in a cache, cookie or database field.

Validating while you minify

Catch invalid JSON, since the tool parses before it compresses.

When to use it — and when not to

Good for

  • Compressing JSON to one line
  • Saving bytes in payloads and configs
  • Confirming JSON is valid as you minify
  • Inlining JSON into code

Not the best choice for

  • JSON with comments or trailing commas (JSONC/JSON5)
  • Preserving very large integers exactly
  • Keeping duplicate keys
  • Pretty-printing (use a formatter instead)

To go the other way and indent JSON for reading, use a JSON formatter. For JSON with comments or trailing commas, strip those or use a JSON5-aware tool. To keep huge identifiers exact, store them as strings before minifying.

Frequently Asked Questions

Does minifying change my data?
No. It only removes whitespace that was there for readability. The keys, values and structure are identical — the output is the same JSON on one line.
Does it check that my JSON is valid?
Yes, as a side effect. It parses the JSON before minifying, so invalid input is rejected with an error rather than producing broken output. A successful minify means the JSON was valid.
Why does it reject my JSON with comments?
Comments are not part of standard JSON. Because the tool uses a real parser, JSONC or JSON5 features like comments and trailing commas are rejected. Remove them first, or use a tool that supports those dialects.
How much smaller will my JSON be?
It depends on how much indentation it had. Heavily indented JSON can shrink noticeably, since every level of spaces and every line break is removed. The data itself does not change size.
Are spaces inside my strings removed?
No. The tool understands strings, so any spaces inside a string value are kept. Only the insignificant whitespace between structural tokens is removed.
What happens to very large numbers?
JSON numbers are read as double-precision floats, so an integer beyond about 2 to the 53rd can come back rounded. If you have long numeric identifiers, store them as strings to keep them exact.
What if my object has duplicate keys?
The parser keeps only the last value for a repeated key, so the minified object can have fewer keys than your input. That is standard JSON-parsing behaviour.
Is this different from a regex minifier?
Yes. It parses the JSON rather than stripping characters with patterns, so it can never turn valid JSON into broken JSON, and it validates as it goes. Regex strippers offer neither guarantee.
Can I get my formatted JSON back afterwards?
Yes. Minifying is reversible in the sense that a JSON formatter can re-indent the compact output. The data is the same; only the whitespace differs.
Is my JSON uploaded anywhere?
No. It is parsed and minified entirely in your browser. Nothing is sent to a server, so payloads with secrets stay on your device.
Does it sort or reorder my keys?
No. Keys are kept in the order the parser reads them (insertion order for string keys), so the structure is preserved apart from any duplicate-key collapse.
Will it work on a very large JSON file?
It can, within your browser's memory. Extremely large files may be slow since the whole structure is parsed at once, but typical payloads and configs minify instantly.

References

Minifies by genuinely parsing the JSON and re-serialising it with no spaces, so it also validates as a side effect; honest about the parse-level limits it shares with any JSON tool.

PopularHot

JSON Formatter

JSON Formatter for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

JSON Validator

JSON Validator for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Base64 Encoder

Base64 Encoder for developers — instant, offline-style and privacy-safe.

DeveloperOpen Tool
Popular

Hash Generator

Fast, free Hash Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Popular

UUID Generator

Fast, free UUID Generator that runs entirely client-side in your browser.

DeveloperOpen Tool
Trending

CSS Minifier

Fast, free CSS Minifier that runs entirely client-side in your browser.

DeveloperOpen Tool

Ready to try the JSON Minifier?

It is free, private and runs entirely in your browser — no sign-up, no uploads, no limits.