Free online tool · nothing is uploaded

JSON minifier, beautifier and compressor

Paste JSON, drop a file, or open one. Strip the whitespace, tidy it up, or check it and be told the exact line and column where it breaks. Then go further than a minifier can: compress removes the repeated keys and repeated values a minifier leaves behind, losslessly, and hands back something that is still ordinary JSON.

Everything runs in this tab. Your document is never sent to us or to anyone else — read the code that runs this page if you would rather check than take our word for it.

As pasted
Minified
Compressed
Saving
Minified
Compressed
Both + gzip

Your JSON

Result — output

Try it with
Loading the compression library…
What minifying leaves behind

Whitespace is the small half of the problem

Minifying removes the spaces and newlines. What it cannot touch is the repetition — and in record-shaped JSON, the repetition is most of the file.

Every key, every row

A thousand records with ten fields is ten thousand copies of ten key names. A minifier keeps all of them, because they are data. Compression writes each name once and refers to it.

Values that never change

A currency field that is always "GBP". A country that is always the same. A __typename repeated on every node. Written once, restored on every row.

Values from a short list

A status column with four possible values, spelled out a thousand times. It becomes a list of four and a column of small integers.

It is still JSON. No binary framing, no base64, no custom parser. The compressed document goes anywhere the original went — an HTTP body, a WebSocket frame, a jsonb column, localStorage, a log line — and JSON.parse reads it.
Measured, not claimed

What each step actually saves

Real documents, run through the same code this page uses. Every figure is round-tripped and checked against the original before it is reported.

Sizes for six document shapes, minified and compressed, with and without gzip
Document Minified Compressed Saved Compressed + gzip Saved over gzip
API record set — 1,000 users206.2 KB54.8 KB73%13.3 KB20%
Nested API response — orders with lines96.5 KB39.9 KB59%9.4 KB6%
Time series — 2,000 readings166.7 KB44.3 KB73%11.4 KB19%
Structured logs — 1,500 lines237.3 KB57.3 KB76%21.2 KB13%
GeoJSON — 400 features58.9 KB31.6 KB46%6.9 KB5%
Small config file — little repetition3.1 KB2.2 KB29%0.5 KB−22%

The last row is in the table on purpose. Most JSON meets gzip on its way out of a server, and on a small document with little repetition the envelope costs more than it saves. This is a tool for record sets, logs, time series and API responses — and the meter at the top of this page tells you which side of the line your document falls on before you commit to anything.

The same thing, in your project

This page is a thin wrapper around a package you can install

The compression on this page is json-compress, MIT licensed and open source, with six interoperable implementations — JavaScript, .NET, Python, PHP, Go and Rust. This page loads the JavaScript one from the public repository over a CDN, and what it produces here decompresses in any of the others.

In a browser, nothing installed

<!-- straight from the repository -->
<script src="https://cdn.jsdelivr.net/gh/eharain/JSON-Compress@1.0.2/javascript/dist/json-compress.min.js"></script>

<script>
  const small = jsonCompress.compress(myData);
  const back  = jsonCompress.decompress(small);
</script>

About 7 KB over the wire. One global, jsonCompress, carrying the whole API.

In Node, Deno or a bundler

$ npm install @tech-style/json-compress
import { compress, decompress, measure }
  from '@tech-style/json-compress';

const small = compress(records);   // still JSON
const back  = decompress(small);   // byte for byte

await measure(records);           // what it would save

And in five other languages, writing the same bytes

json-compress packages by language and registry
LanguageInstallRegistry
JavaScript / TypeScriptnpm install @tech-style/json-compressnpm ↗
.NETdotnet add package TechStyle.JsonCompressNuGet ↗
Pythonpip install json-compressPyPI ↗
PHPcomposer require tech-style/json-compressPackagist ↗
Gogo get github.com/eharain/JSON-Compress/gopkg.go.dev ↗
Rustcargo add json-compresscrates.io ↗

Every one of them ships a command line called json-compress as well, with the same verbs. A document compressed on this page decompresses in any of them, and vice versa — how that is guaranteed →

Questions

The things people ask first

Is my data uploaded anywhere?

No. Every button on this page runs in your browser. There is no request carrying your document — not to us, not to a third party, not to an analytics service. The page fetches one JavaScript file from a public CDN when it loads, and after that it works with the network off. The source of this page is right there to read.

Is compression lossless?

Yes. decompress(compress(x)) returns exactly what you put in — the same values, and the same key order, including in packed record sets. A key that was missing stays missing rather than becoming null. It is checked against two thousand randomly generated documents on every build.

Can I compress here and decompress in my own code?

Yes, and in any language. json-compress has six implementations — JavaScript, .NET, Python, PHP, Go and Rust — and they all write the same bytes for the same document. Anything compressed on this page is restored exactly by any of them, and anything they compress can be pasted back in here and decompressed.

Can I still read the output?

It is valid JSON, so any parser reads it — but the key names are replaced by short tokens, so it is not meant for human eyes. Paste it back and press Decompress to get the original document.

Should I use this instead of gzip?

Alongside, not instead. Gzip is transport compression and this is structural, so they stack. On record-shaped data, compressing first and then gzipping is another 13–20% smaller than gzip alone. On a small document with little repetition, it is not — and the meter tells you.

How big a file can it handle?

Up to about 25 MB, which is where a browser tab starts to struggle rather than where the library does. For anything larger, install the package and use the command line: json-compress stats big.json.

What does “Validate” tell me?

The exact line and column your document stops being valid JSON, with the line printed and a caret under the character. It knows the usual culprits by name: single quotes, trailing commas, True and None, leading zeros, unterminated strings, bad escapes.

Sending a lot of JSON around?

We build the systems that produce it — APIs, data platforms, integrations. If bandwidth, storage or payload limits are becoming a problem, that is a conversation we have often.