Compression & Serialization Benchmarks
One dataset, one machine, one timing rule: how far apart gzip, brotli, zstd, deflate and LZ4 actually are. Every number is tagged with the runtime it depends on, because the snippet you copy out of a tutorial is usually not the C library.
Decompression throughput · orders JSON MB/s of input · 553,706 B
Compression throughput · orders JSON MB/s of input
Full results for · orders JSON
| Codec | Runtime | Output | Ratio | Compress MB/s | Decompress MB/s |
|---|---|---|---|---|---|
| zstd-19 | Native C | 29,618 B | 5.3% | 1.1 | 524.5 |
| lz4-blockLZ4 block, no header | WASM | 97,646 B | 17.6% | 387.2 | 480.7 |
| zstd-1 | Native C | 45,911 B | 8.3% | 362.9 | 456.4 |
| deflate-9 | Native C | 47,542 B | 8.6% | 37.4 | 413.6 |
| deflate-6 | Native C | 52,133 B | 9.4% | 79.5 | 404.7 |
| gzip-9 | Native C | 47,554 B | 8.6% | 36.3 | 396.0 |
| brotli-11 | Native C | 27,870 B | 5.0% | 0.4 | 386.6 |
| gzip-6 | Native C | 52,145 B | 9.4% | 73.1 | 367.6 |
| brotli-4 | Native C | 43,625 B | 7.9% | 80.1 | 272.8 |
| gzip-1 | Native C | 65,856 B | 11.9% | 234.4 | 269.4 |
| zstd-3zstd's own default level | Native C | 45,734 B | 8.3% | 167.5 | 252.5 |
| brotli (wasm)default quality | WASM | 27,871 B | 5.0% | 0.2 | 219.6 |
| gzip (fflate) | Pure JS | 54,146 B | 9.8% | 22.1 | 142.3 |
| lz4-frameLZ4 frame, has header | Pure JS | 95,766 B | 17.3% | 154.6 | 124.2 |
| deflate (pako) | Pure JS | 52,133 B | 9.4% | 26.3 | 102.3 |
| gzip (pako) | Pure JS | 52,145 B | 9.4% | 26.2 | 79.0 |
| gzip (Web API)browser-native gzip | Web API | 52,145 B | 9.4% | 49.3 | 75.4 |
| deflate (Web API)browser-native deflate | Web API | 52,133 B | 9.4% | 51.9 | 65.8 |
| deflate (fflate) | Pure JS | 54,128 B | 9.8% | 22.9 | 57.8 |
Serialization: the same 1,000 records
Protobuf is 44.6% of the JSON size (−55.4%). Encode 8.75 ms vs JSON.stringify 4.97 ms; decode 3.61 ms vs JSON.parse 4.45 ms.
Methodology
- How
- median of 15 timed rounds (5 for the brotli quality-11 rows) after 2 warmups; all outputs round-trip verified; bytes exact, MB/s indicative
- Runtime
- v24.22.0 · win32-x64
- Combinations
- 114 rows (19 codecs × 6 payloads), all round-trip verified
- Libraries
- protobufjs@8.8.0 · pako@3.0.1 · lz4js@0.2.0 · brotli-wasm@3.0.1 · lz4-wasm@0.9.2 · fflate@0.8.3
- What the Web API rows really are
- Every row, including the CompressionStream ones, was timed inside Node — it ships the same API the browser does. The web-api, wasm and pure-JS rows are therefore codecs a browser can run, measured on a server. A browser would move the MB/s; it would not move a single output byte.
- Generated
- 2026-11-18T16:24:04.726Z
Byte counts are exact and reproducible; MB/s is indicative — two consecutive runs of this harness on 2026-11-19 agreed on all 114 rows byte for byte, while the median MB/s figure moved 25.2%, 127 of the 227 figures moved by more than 20%, and the worst single figure by 347%. The dataset, the scripts, the pinned dependency manifest and the bundled JS fixture are all public: results.json · results.csv · bench.mjs · payloads.mjs · zstd-ladder.mjs · zstd-ladder.csv · zstd-params.mjs · zstd-params.csv · overhead.mjs · compression-overhead.csv · package.json · package-lock.json · real-js-chunk.js
To re-run it: put bench.mjs, payloads.mjs, package.json, package-lock.json and real-js-chunk.js in one folder and run npm ci && node bench.mjs — Node 22.15.0 or newer (v23.8.0 and up on the non-LTS line), no build step: that is when node:zlib grew zstd. An older Node still completes the run but emits 96 rows instead of 114 and prints why. It emits one row per codec x payload pair and stops with an error rather than quietly dropping a payload. The level ladder is the same five files plus node zstd-ladder.mjs and the crossover sweep is the same five files plus node overhead.mjs , and the forced-parameter sweep (192 rows of strategy and windowLog against the level dial) is the same five files plus node zstd-params.mjs.
All raw data is public: results.json · results.csv · datasets page — the data files are CC BY 4.0; reuse them with credit to DevKit (hcatree.com).
How to read these numbers
On orders JSON the three deflate implementations produce exactly the same 52,133 bytes: Node zlib at 79.5 MB/s, pako in pure JS at 26.3 MB/s, and the browser's own CompressionStream at 51.9 MB/s. Same format, same level, same output — the only variable left is the implementation.
gzip level 1 buys 234 MB/s by spending 38% more output; level 9 is 8.59% at 36.3 MB/s; brotli-11 manages 0.4 MB/s, 586× slower than gzip-1. "gzip is fast" with no level attached is a claim about nothing.
Across all 19 codecs on random bytes, every compression ratio lands between 100.0% and 100.4% — true randomness is not compressible, so nobody wins there. Switch to high-repeat text and every format looks brilliant. Change the payload column and the ranking reshuffles.
Chromium's CompressionStream accepts gzip, deflate and deflate-raw and throws on both brotli and zstd — measured here. Safari 18.4 and Firefox 147 have brotli; Chrome still does not. zstd exists in no browser's implementation of this API, and in Firefox 138 only behind a flag. So brotli in a browser means carrying WASM: 0.2 MB/s to compress. That is not brotli being slow — it is what happens when a C library is swapped for a wasm one. Decompression is still 220 MB/s, so the whole cost sits on whichever side does the compressing.
On high-repeat text, brotli quality 3 emits 52 bytes and quality 11 emits 61 — the maximum setting is 9 bytes *bigger*, at 29× the cost. zstd holds 79 bytes flat from level 1 to 12 on the same payload, then goes to 80 above 15. "Turn it up" is not a free conservative choice; sometimes it is simply the worse one.
On orders JSON zstd-11 gives 32424 bytes at 23 MB/s and brotli-9 gives 32361 bytes at 13.1 MB/s: 63 bytes apart, zstd 1.76× faster. Brotli's walk from 9 to 11 buys another 14% for 44× the time, and zstd from 19 to 22 saves 8 bytes. The cliff is not a brotli flaw — it is the shape of entropy coding, and the only question is which rung you jump off.