Skip to content
Tools

JSON Minifier

Reduce JSON size instantly by removing unnecessary spaces, tabs and line breaks while preserving the original data. Everything runs locally in your browser.

Visible pane

Paste or upload JSON to minify.

Waiting for input

Everything happens locally in your browser. Your JSON is never uploaded.

What is JSON minification?

Minifying JSON means removing every character that a parser does not need: the spaces used for indentation, the line breaks between properties, the space after a colon. What is left is the same document, written in the fewest bytes the syntax allows.

This is possible because whitespace between tokens carries no meaning in JSON. It exists for people. A parser reading { "id": 1 } and a parser reading {"id":1} produce exactly the same value, so a minifier can move freely between them without ever touching the data.

Formatted — 86 bytes
{  "id": 1042,  "name": "Ada Lovelace",  "roles": [    "admin",    "editor"  ]}
Minified — 60 bytes, identical data
{"id":1042,"name":"Ada Lovelace","roles":["admin","editor"]}

Twenty-six bytes gone from a document of eighty-six, and nothing lost. The word every in the first paragraph is doing real work, though: whitespace inside a string is data, not decoration. "Ada Lovelace" keeps its space, because removing it would change the value rather than its presentation.

Why minify JSON?

Because indentation is a cost you pay on every request, and it buys nothing once the document has left the hands of the person who was reading it.

  • Faster API responses. Fewer bytes means fewer packets and less time on the wire. On a slow or high-latency connection that is the difference between a response arriving in one round trip and arriving in two.
  • Reduced bandwidth. A third off a payload served a million times a day is a third off that line of the bill, at both ends. For a mobile user on a metered plan, it is their money as well as yours.
  • Smaller files. Bundled configuration, embedded fixtures and cached documents all take less room — in the artefact, in the cache, and in whatever storage charges you by volume.
  • Better performance. Parsing gets marginally quicker because there is less to skip, and payloads embedded in a page block rendering for less time. The transfer saving is the larger half; both are real.

It is worth being honest about the size of the win. If your server already compresses responses — and it should — gzip and brotli handle repetitive indentation very well, so minifying on top of compression saves less than the raw byte counts suggest. It still saves, it costs nothing at runtime, and it stacks with compression rather than competing with it.

How JSON minification works

A naive minifier deletes whitespace with a search and replace. That works right up until a string contains a space, at which point it silently corrupts the document. A correct minifier never edits the text at all. It works in three steps:

  1. 1. Parse. The document is read into actual data — objects, arrays, strings, numbers, booleans and nulls. If it does not parse, minification stops here and the error is reported instead, because there is nothing to re-serialise.
  2. 2. Serialise without indentation. The parsed data is written back out with no indent, no line breaks and no space after colons or commas. Every string is re-escaped by the serialiser, so quotes and backslashes inside values are handled correctly rather than hopefully.
  3. 3. Measure. The bytes before and after are compared, along with the structure — objects, arrays, keys and nesting depth — so the result comes with evidence rather than a claim.

The round trip through real data is what makes the guarantee possible: the output is produced by a serialiser, so if the input parsed, the output parses. It is also why the difference between whitespace that matters and whitespace that does not never has to be guessed at — by the time anything is written out, a string is a string and indentation no longer exists.

Whitespace inside a string is data, and survives
{  "note": "two  spaces  inside"} →  {"note":"two  spaces  inside"}

Benefits of minified JSON

  • It is lossless.The output parses to a value identical to the input’s. Nothing is approximated, reordered or dropped.
  • It is free at runtime. Minification happens once, at build time or at serialisation. Nothing downstream has to do extra work to read the result.
  • It is universally readable. Minified JSON is ordinary JSON. Every parser accepts it; no client needs to know anything has been done.
  • It is reversible. Any formatter will expand it again — a paste into the JSON formatter puts the indentation back — so nothing is lost for debugging.
  • It compounds with compression. Smaller input to gzip is smaller output from gzip, and the two techniques do not interfere.
  • It exposes accidental bloat. Watching a document shrink by half is often the moment someone notices how much of the payload was never needed at all.

JSON minifier vs JSON formatter

They are the same operation pointed in opposite directions, and both are lossless. What differs is who the output is for.

A formatter writes for people. It adds indentation and line breaks so structure is visible at a glance: one property per line, nesting shown by depth. That makes a document reviewable, diffable and debuggable, at the cost of bytes that mean nothing to a machine.

A minifier writes for machines. It removes exactly those bytes. The result is unreadable to a person and identical to a parser.

The practical differences:

  • Reviewing. A formatted document diffs line by line and can be read in a pull request. A minified one is a single line, so a text diff can only say that it changed — for those you want a diff that compares the parsed documents instead.
  • Transferring. A minified document is around a third smaller. That is the entire point, and it is why the formatted version rarely belongs on the wire.
  • Debugging. Formatted output shows you where you are. This is why browsers pretty-print JSON responses in their network panel — the transfer is minified, the display is not.
  • Storing. Source control wants the readable version; caches, queues and object stores want the small one.

So the two are not alternatives to choose between. Keep the formatted version where humans work and the minified version where bytes are counted, and convert between them freely — a round trip through both changes nothing at all.

Common use cases

Anywhere a document is written once and transferred many times, the indentation is paid for repeatedly and read never.

REST APIs

Response bodies are paid for on every single request. Serialising without indentation is usually a one-line change to the encoder and takes a third off the payload for the whole life of the endpoint.

Configuration files

Config shipped inside a bundle or an image is read by machines, not reviewed by people. Keep the readable copy in the repository and minify the one that gets deployed.

Web applications

State embedded in a page — hydration payloads, feature flags, translation catalogues — is downloaded before anything can render. Whitespace there is latency, not readability.

Mobile applications

On a metered or unreliable connection, every kilobyte is a real cost to a real person. Smaller payloads mean fewer round trips, fewer retries and less battery spent on the radio.

Data transfer and storage

Message queues, log pipelines and document stores charge by volume. Minifying at the point of writing compounds across millions of records.

Server responses and caching

Smaller responses fit more comfortably into caches and CDN tiers, and a cached object that is a third smaller is a third cheaper to hold and to serve.

Best practices

  • Minify at the boundary, not at the source. Keep the readable document in source control and minify during the build or as the response is serialised. Committing minified JSON costs you every future code review.
  • Compress as well, not instead. Gzip or brotli will do more for a large payload than minification will. Do both — they stack, and neither interferes with the other.
  • Validate before you ship. Minifying proves a document parses, which makes it a cheap last check in a pipeline. Anything that fails to minify was never going to work downstream either — and when it fails, the JSON validator reports every problem in the document rather than stopping at the first.
  • Do not hand-edit minified JSON. Expand it, change it, minify it again. Editing a single 400 KB line is how stray commas get introduced.
  • Measure before you optimise. If a document loses only a few per cent, the bytes were never the problem — look at what the payload contains instead. The statistics here are there to answer that question honestly.
  • Consider whether the field is needed at all. The cheapest byte is the one you never send. Minification is the last step of trimming a payload, not the first.

Frequently asked questions

Is this JSON minifier free?

Yes. Minifying, validating, the statistics, search, uploads and downloads are all free, with no account, no usage cap and no paid tier. Nothing is held back.

Is my JSON uploaded anywhere?

No. Everything happens inside your browser. The document you paste, drop or open is parsed and re-serialised by JavaScript running on your own machine — it is never sent over the network, stored or logged. You can confirm this by watching your browser's network panel, or by disconnecting from the internet after the page loads: the tool keeps working.

Does minifying change my data?

No. Only whitespace between tokens is removed. Keys keep their names and their order, numbers keep their values, strings keep every character including the spaces inside them, and the nesting is untouched. Parse the input and parse the output and you get two identical values — which is the definition the tool is built to satisfy.

Is the output still valid JSON?

Yes, and more reliably than if the whitespace were stripped with a search and replace. The document is parsed into data first and then written back out without indentation, so the output is generated by a serialiser rather than edited by hand. If the input parses, the output parses.

Can I minify large JSON files?

Yes. Documents up to roughly 20 MB are supported. Anything over about 120 KB is parsed in a background Web Worker so the page stays responsive, and the editors only render the lines currently on screen. The statistics panel reports how long the work actually took.

How much smaller will my JSON get?

It depends entirely on how it was formatted. A document indented with four spaces and one value per line often loses 30–50% of its bytes, because most of those bytes were indentation. A document that was already compact may lose almost nothing. The tool shows the real figure for your document rather than a general claim.

What is the difference between minifying and formatting?

They are opposites, and both are lossless. Formatting adds whitespace so a person can read the document; minifying removes it so a machine can transfer it in fewer bytes. Neither changes the data. In practice you want both at different moments: the formatted version in source control where it is reviewed, the minified version on the wire where it is paid for.

Should I minify JSON in source control?

Usually not. A minified file is one enormous line, so a diff can only tell you that the line changed — it cannot show you what changed inside it, and it cannot be reviewed. Keep the readable version in the repository and minify as part of the build or the response, where the size actually costs something.

Does minified JSON parse faster?

Slightly, because there are fewer bytes to read and fewer whitespace characters to skip, but the saving is small compared with the transfer. The real win is bandwidth: fewer bytes over the network, fewer bytes in cache, fewer bytes in storage. Parsing was rarely the bottleneck.

Is minifying the same as compressing with gzip?

No, and they stack. Minifying removes bytes that carry no meaning; gzip and brotli re-encode whatever bytes remain. Compression is very good at repetitive indentation, so minifying an already-compressed response saves less than the raw numbers suggest — but it still saves, and it costs nothing at runtime because it happens once rather than per request.

Can I download the minified JSON?

Yes. The download button saves the result as data.min.json, and the copy button puts it on your clipboard. Both are also on keyboard shortcuts, listed in the options panel.

What happens if my JSON is invalid?

Nothing is minified. Producing output from a document that does not parse would mean guessing at what was meant, so the tool reports the problem instead: what went wrong, the exact line and column, a plain-language explanation, and a button that jumps the cursor there.

Can I search inside the JSON?

Yes. The search bar runs over either the input or the minified output — pick which with the toggle beside it, or press Ctrl+F (Cmd+F on a Mac). Matches are highlighted and counted, and the arrows step through them, scrolling each one into the middle of the view. This is the quickest way to check that a particular key survived minification.

Does minifying remove comments?

There are no comments to remove: JSON has no comment syntax. A document containing // or /* */ is not valid JSON and will be reported as an error rather than quietly stripped. If you are working with JSONC or JSON5, strip the comments with a tool that understands those formats before minifying here.

Does the tool work offline?

Once the page has loaded, yes. All parsing and minifying is local, so you can disconnect and keep working. A connection is only needed to load the page in the first place.

Popular tools

↑ ↓NavigateOpenEscClose