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
- —
Your JSON
Result — output
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.
jsonb column, localStorage, a log line — and JSON.parse reads it.
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.
| Document | Minified | Compressed | Saved | Compressed + gzip | Saved over gzip |
|---|---|---|---|---|---|
| API record set — 1,000 users | 206.2 KB | 54.8 KB | 73% | 13.3 KB | 20% |
| Nested API response — orders with lines | 96.5 KB | 39.9 KB | 59% | 9.4 KB | 6% |
| Time series — 2,000 readings | 166.7 KB | 44.3 KB | 73% | 11.4 KB | 19% |
| Structured logs — 1,500 lines | 237.3 KB | 57.3 KB | 76% | 21.2 KB | 13% |
| GeoJSON — 400 features | 58.9 KB | 31.6 KB | 46% | 6.9 KB | 5% |
| Small config file — little repetition | 3.1 KB | 2.2 KB | 29% | 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.
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
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
| Language | Install | Registry |
|---|---|---|
| JavaScript / TypeScript | npm install @tech-style/json-compress | npm ↗ |
| .NET | dotnet add package TechStyle.JsonCompress | NuGet ↗ |
| Python | pip install json-compress | PyPI ↗ |
| PHP | composer require tech-style/json-compress | Packagist ↗ |
| Go | go get github.com/eharain/JSON-Compress/go | pkg.go.dev ↗ |
| Rust | cargo add json-compress | crates.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 →
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.