Developer Tools

Gzip vs Brotli vs Zstd: Which HTTP Compression to Serve

Gzip vs Brotli vs Zstd benchmarked on React, Bootstrap, HTML and JSON: sizes, speeds, 2026 browser support, Cloudflare defaults and configs to copy.

TechLogHub Editorial
December 4, 2026
14 min read
0 views

Share Article

TechLogHub cover: one response compressed with gzip, Brotli and zstd, with bars showing the bytes each sends

Gzip vs Brotli vs Zstd: Which HTTP Compression to Serve

Quick answer: Serve Brotli at quality 11 for static assets you can precompress at build time. It made the smallest files in every test we ran, 11–26% smaller than gzip -6. Serve zstd, or Brotli at quality 4–5, for responses you compress on the fly. Zstd at level 12 was 9–11% smaller than gzip on text, and it compresses fast. Keep gzip as the fallback for every client. Zstd has been Baseline since February 2026 (Chrome 123, Firefox 126, Safari 26.3). Cloudflare's Free plan now compresses with zstd by default.

Compression is the cheapest performance win on the web, and most sites leave part of it on the table without knowing. We benchmarked gzip, Brotli and Zstandard on real front-end files (React DOM, Bootstrap CSS, lodash and a large HTML document), then checked what our own site actually sends. That check turned up a split we did not expect. Our HTML goes out as zstd, while our 650 KB stylesheet and largest JavaScript chunk still go out as gzip.

This guide covers what each encoding is, how the benchmarks came out, who supports what in December 2026, and a configuration you can copy. It assumes you know what Accept-Encoding is. If cache headers are the other half of your performance work, pair it with our Cache-Control guide.

The three encodings in one table

gzipBrotli (br)Zstandard (zstd)
SpecDEFLATE-based gzip formatRFC 7932 (July 2016, Google; updated by RFC 9841)RFC 8878 (Feb 2021) + RFC 9659 (Sept 2024) for HTTP window size
Levels used in this test6, 9 (range 1–9)4, 5, 11 (range 0–11)3, 12, 19
Window for HTTPSmall, fixed by DEFLATEUp to 16 MiB − 16 BCapped at 8 MB by RFC 9659
Built-in dictionaryNoYes (web-oriented static dictionary)No (custom dictionaries via dcz)
Browser supportUniversalUniversal in current browsersBaseline "newly available" since 2026-02-11
Sweet spotFallback; legacy clientsPrecompressed static assetsDynamic responses at the edge

Two details in that table matter more than they look. First, RFC 9659 turned zstd's 8 MB window from a recommendation into a requirement for HTTP: decoders must handle windows up to 8 MB, and encoders must not exceed it. Chrome's Intent to Ship states the same limit and says Chrome caps the window frame at 8 MB to prevent excessive memory use. If you compress with a zstd library and crank the level or enable long-distance matching, you can produce frames a browser will refuse. Second, MDN's Content-Encoding reference now lists dcb and dcz, dictionary-compressed Brotli and Zstandard. That is where the next round of gains will come from. We cover it briefly below.

Benchmark: four real files, eight settings

We compressed four files that look like what a modern site actually ships:

  • react-dom-client.production.js from react-dom 19.3.1: 625,168 bytes
  • bootstrap.min.css from Bootstrap 5.3.9: 232,360 bytes
  • lodash.min.js from lodash 4.18.1: 73,234 bytes, already minified
  • A 145,038-byte HTML page generated by pydoc for Python's typing module

Tools: Python 3.13.18's gzip module, the brotli package 1.2.1 and zstandard 0.25.0, on a 2-vCPU Intel Xeon at 2.10 GHz. Times are the median of 7 runs. Every output was decompressed and compared byte for byte with the input.

Compressed size (bytes, and change vs gzip -6)

Settingreact-dom (625 KB)bootstrap.css (232 KB)typing.html (145 KB)lodash.min (73 KB)
gzip -6111,37030,84219,53325,938
gzip -9110,586 (−0.7%)31,030 (+0.6%)19,128 (−2.1%)25,898 (−0.2%)
br 4115,138 (+3.4%)33,039 (+7.1%)20,055 (+2.7%)26,678 (+2.9%)
br 5105,082 (−5.6%)28,277 (−8.3%)18,080 (−7.4%)25,217 (−2.8%)
br 1189,698 (−19.5%)22,775 (−26.2%)15,685 (−19.7%)23,030 (−11.2%)
zstd 3121,605 (+9.2%)34,431 (+11.6%)21,050 (+7.8%)27,463 (+5.9%)
zstd 12101,819 (−8.6%)27,823 (−9.8%)17,445 (−10.7%)25,315 (−2.4%)
zstd 1992,294 (−17.1%)26,027 (−15.6%)16,580 (−15.1%)24,463 (−5.7%)

Compression and decompression time (ms, median of 7)

Settingreact-dom compressreact-dom decompressbootstrap compressbootstrap decompress
gzip -612.500.852.580.23
gzip -923.380.854.960.23
br 46.531.202.180.39
br 511.531.103.470.35
br 111,070.961.49358.870.37
zstd 34.170.930.580.17
zstd 1228.960.7712.830.15
zstd 19216.880.4692.950.25

What the numbers say

Brotli 11 is the size champion, and it is slow. It beat everything on all four files, by 11–26% over gzip -6. The CSS file gained most. Brotli's built-in static dictionary is full of common web tokens, so class names and property names compress especially well. But Brotli 11 took more than a second for React DOM. That is fine once per build. It is unacceptable per request.

Zstd 19 gets most of Brotli's gain in a fifth of the time. On React DOM, zstd 19 came within 3 percentage points of Brotli 11 (−17.1% vs −19.5%) in 217 ms instead of 1,071 ms. It also decompressed fastest of all, at 0.46 ms. On CSS the gap was wider (−15.6% vs −26.2%), which again points to Brotli's dictionary.

At "fast" levels, gzip -6 is not the loser you'd expect. Zstd 3 is the level most servers and libraries pick by default. Node's own docs give ZSTD_CLEVEL_DEFAULT as 3. It produced files 6–12% larger than gzip -6, although it compressed 2.6–4.4× faster. Brotli 4 was also slightly larger than gzip -6. If a CDN advertises "zstd" and you assume smaller responses, check the level. The win at low levels is CPU time, not bytes.

The useful dynamic setting is in the middle. Brotli 5 and zstd 12 both beat gzip -6 on every file, at compression costs between 2 and 29 ms. Brotli 5 was faster and zstd 12 slightly smaller on three of four files. Either is a sound choice for on-the-fly compression of HTML and JSON.

gzip -9 is pointless. It took 1.5–1.9× the time of gzip -6 for, at best, a 2% gain, and on Bootstrap it was actually larger. If you are still on gzip, leave it at 6, or lower if CPU is tight. Note that nginx's own gzip_comp_level defaults to 1.

Minified code compresses less. lodash.min.js barely moved: the best setting saved only 11% over gzip. Minification and compression overlap; both remove redundancy. Minify first (our JS minifier and CSS minifier are free), then compress, and expect the compression delta between algorithms to shrink.

A dynamic case: a 246 KB JSON API response

Static files are only half the story. API responses are generated per request, so they can only be compressed on the fly. We generated a JSON payload shaped like a directory listing: 1,000 product records with ids, slugs, categories, votes, tags and timestamps, 245,880 bytes in total. Then we ran the same encoders over it (median of 9 runs):

SettingSizevs gzip -6Time
gzip -629,942 B (12.2%)baseline4.26 ms
br 527,193 B (11.1%)−9.2%6.36 ms
zstd 331,372 B (12.8%)+4.8%0.60 ms
zstd 1224,362 B (9.9%)−18.6%13.10 ms
br 11 (for reference)21,118 B (8.6%)−29.5%415.01 ms

JSON is where zstd's mid-range levels shine. Zstd 12 cut nearly a fifth off gzip in 13 ms, about twice as much as Brotli 5 saved, and it is still fast enough to run per request on a busy endpoint. If your biggest responses are JSON lists, zstd at a mid level is the strongest on-the-fly option we tested. If CPU is the constraint, zstd 3 compresses seven times faster than gzip -6 and loses only about 5% in size.

Before blaming the encoder, check the payload. Pretty-printed JSON with two-space indentation compresses well, but it still costs parse time. Paste a sample into our JSON formatter to see its minified size before and after.

Decision table: what to serve, by setup

Your setupStatic assetsHTML / JSON on the flyNotes
Static host or CDN serving prebuilt filesPrecompressed .br (q11) + .gzn/aCheck the host actually serves the .br sibling
nginx originbrotli_static + gzip_staticbrotli_comp_level 5, gzip 6Set *_types; defaults cover only text/html
Cloudflare Free in frontWhatever the origin sends (br or gzip)zstd by defaultOrigin requests ask only for br, gzip
Cloudflare Pro / BusinessWhatever the origin sendsBrotli by defaultzstd via Compression Rules
Node / Express APIPrebuilt files via a static serverzstd 12 → br 5 → gzip 6Send Vary: Accept-Encoding
Next.js with next startgzip by defaultgzip by defaultMove compression to the proxy for br/zstd

Who supports zstd in December 2026

The web-features explorer marks Zstandard content-encoding Baseline "newly available" since 2026-02-11. It is expected to become "widely available" on 2028-08-11. The browser timeline:

BrowserFirst version with zstd content-encodingReleased
Chrome1232024-03-19
Edge1232024-03-22
Firefox1262024-05-14
Safari (macOS and iOS)26.32026-02-11

One caveat on Safari. caniuse marks desktop Safari 26.0 onward as "partial support" without explaining why, while iOS Safari is fully supported from 26.3. The WebKit tracking bug was still open at last update. caniuse puts total zstd support at 86.45% of global usage (October 2026 data). That is well short of the near-universal support for gzip, which is why fallback negotiation is mandatory, not optional.

Browsers only advertise zstd over HTTPS. The Chromium thread confirms zstd is only advertised on secure connections. That is not a problem on any production site in 2026, but it explains why a local http:// dev server never sees zstd in Accept-Encoding.

Do not confuse this with CompressionStream. caniuse lists the "zstd" format for the CompressionStream API at 0% support: disabled by default in Firefox and absent elsewhere. Browsers can decode zstd responses, but JavaScript cannot yet produce zstd in the browser.

What our own site sends: a split we did not plan

techloghub.com sits behind Cloudflare. We loaded the homepage in Chrome 158 and read the Resource Timing entries and response headers from the console:

// run in DevTools on any page
const nav = performance.getEntriesByType("navigation")[0];
console.log(nav.decodedBodySize, nav.encodedBodySize);
const r = await fetch(location.pathname + "?v=" + Date.now());
console.log(r.headers.get("content-encoding"));
ResourceDecodedOn the wireEncoding
Homepage HTML445,756 B49,860 B (11.2%)zstd
/tools and a blog post (HTML)~854K / ~304K charactersnot measuredzstd
Main stylesheet647,169 B84,112 B (13.0%)gzip
Largest JS chunk391,216 B102,332 B (26.2%)gzip

The HTML gets zstd, consistent with Cloudflare's documentation, which says Free-plan content is compressed with Zstandard by default (Pro and Business default to Brotli, Enterprise to gzip). For comparison, Chrome's built-in CompressionStream('gzip') squeezed the same homepage HTML (fetched separately, 445,186 bytes) to 64,026 bytes, so zstd at the edge is about 22% smaller than a browser-grade gzip of the same document.

The static assets are a different story. They arrive as gzip. Cloudflare's docs explain the likely mechanism: on every plan, Cloudflare asks the origin for content with accept-encoding: br, gzip, and the origin may answer with Brotli, gzip or nothing. Next.js, according to its compress option docs, gzips rendered content and static files by default under next start. So the origin hands Cloudflare gzip, and gzip reaches the browser. We have not yet proven that chain on our own stack. It is the next thing to test, and the fix candidate is below.

How much is at stake? Our benchmark suggests Brotli 11 would cut a large CSS file by roughly a quarter versus gzip. Applied to an 84 KB transfer, that is on the order of 20 KB on every cold page view, before touching a line of CSS. Treat that as an estimate until we measure it.

Our plan is deliberately boring. First, confirm the chain by requesting one stylesheet straight from the origin and reading its content-encoding. Then switch origin compression off on a staging build, so Cloudflare compresses static files itself, and compare encodedBodySize for the same assets before and after. If the edge picks zstd or Brotli and the numbers drop, it ships. If assets fall back to uncompressed, we revert and precompress at build time instead. Either way, the console snippet above is the test. No guessing from headers alone.

Configuration you can copy

Precompress static assets at build time

Compress once with the slowest, best settings and let the server pick the right file. This shell step after your build writes .br and .gz siblings for every text asset:

find dist -type f \( -name '*.js' -o -name '*.css' -o -name '*.html' -o -name '*.svg' -o -name '*.json' \) \
  -exec brotli -q 11 -k {} \; \
  -exec gzip -6 -k -n {} \;

Then serve them. With nginx, the stock gzip_static module (built with --with-http_gzip_static_module) sends file.gz when the client accepts gzip. Google's ngx_brotli module adds brotli_static for .br files and brotli for on-the-fly compression:

gzip on;
gzip_static on;
gzip_comp_level 6;
gzip_types text/css application/javascript application/json image/svg+xml;

brotli on;
brotli_static on;
brotli_comp_level 5;          # dynamic responses; default is 6
brotli_types text/css application/javascript application/json image/svg+xml;

Two defaults worth knowing. nginx's gzip_types defaults to text/html only, and so does ngx_brotli's brotli_types. Without the lines above, your CSS and JavaScript go out uncompressed when nginx compresses on the fly.

Next.js behind a CDN

If a CDN or reverse proxy in front of Next.js handles compression, the Next.js docs show setting compress: false so the proxy can choose the encoding. They also warn not to disable it unless compression is configured elsewhere:

// next.config.js
module.exports = {
  compress: false, // only if nginx / the CDN compresses responses
};

Before flipping that on a live site, check the result with the console snippet above. The content-encoding of your JS and CSS should change, and encodedBodySize should drop. If it falls back to identity (uncompressed), revert.

Node.js on the fly

Node's node:zlib ships Brotli, and zstd as an API the Node docs mark experimental. We ran this on Node 22.23.5. A minimal negotiation that prefers zstd, then Brotli, then gzip:

import zlib from "node:zlib";

function pickEncoding(accept = "") {
  if (/\bzstd\b/.test(accept)) return "zstd";
  if (/\bbr\b/.test(accept)) return "br";
  if (/\bgzip\b/.test(accept)) return "gzip";
  return null;
}

function compress(body, enc) {
  if (enc === "zstd") return zlib.zstdCompressSync(body, {
    params: { [zlib.constants.ZSTD_c_compressionLevel]: 12 } });
  if (enc === "br") return zlib.brotliCompressSync(body, {
    params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 5 } });
  return zlib.gzipSync(body, { level: 6 });
}
// set Content-Encoding: enc and Vary: Accept-Encoding on the response

// on typing.html (145,038 B): zstd 17,445 · br 18,080 · gzip 19,533

Those outputs match the Python benchmark byte for byte at the same levels. The zlib wrappers make no difference to the result.

Always send Vary: Accept-Encoding when you compress dynamically. Without it, a shared cache can store the zstd response and serve it to a client that only speaks gzip.

Dictionary compression: the next step

MDN now documents two more Content-Encoding values: dcb (dictionary-compressed Brotli) and dcz (dictionary-compressed Zstandard). The idea is that the browser keeps a previous version of a resource, or a purpose-built dictionary, and the server compresses the new response against it. For a JavaScript bundle that changes a few lines per deploy, the transfer can shrink to a fraction of even Brotli 11. It needs coordination between build, server and cache, and support is far behind plain zstd, so treat it as something to watch rather than ship today.

Limits and trade-offs

  • Compression does not fix bloat. A 647 KB stylesheet compressed to 84 KB is still 647 KB the browser must parse. Remove unused CSS before chasing the last 20% of compression.
  • Do not compress already-compressed formats. PNG, JPEG, WebP, AVIF, WOFF2, ZIP and video gain nothing and cost CPU. Keep them out of your *_types lists. For images, choose a better format instead, for example with the image format converter.
  • Tiny responses are not worth it. Cloudflare skips responses under about 50 bytes, and nginx's gzip_min_length defaults to 20. Headers and framing dominate below a few hundred bytes anyway.
  • Server support for zstd is thin. At Chrome's ship time, the Intent to Ship noted that nginx had only a third-party module and Apache, IIS and LiteSpeed appeared to have none. CDNs, not origin servers, are where most zstd gets served today.
  • Benchmarks are machine-specific. Our times come from one 2-vCPU container. The size ratios transfer well; absolute milliseconds do not.

FAQ

Is Brotli better than gzip?

For size, yes. Brotli 11 was 11–26% smaller than gzip -6 on all four of our test files, and Brotli 5 was 3–8% smaller (2.8–8.3%). Brotli 4 was slightly larger than gzip -6, though, so the level matters as much as the algorithm.

Is zstd better than Brotli for the web?

Not for precompressed static assets: Brotli 11 beat zstd 19 on every file we tested. Zstd is strong for dynamic responses, where zstd 12 was 2–11% smaller than gzip -6 at 6–29 ms per file, and it had the fastest decompression. Use both, and let Accept-Encoding decide.

Which browsers support zstd Content-Encoding?

Chrome and Edge 123+, Firefox 126+ and Safari 26.3+ (macOS and iOS). Zstd became Baseline "newly available" on 2026-02-11. caniuse marks desktop Safari as partial and puts total support at 86.45% of global usage, so always keep a Brotli or gzip fallback.

Does Cloudflare support zstd compression?

Yes. Cloudflare's docs say it supports gzip, Brotli and Zstandard to visitors. Free-plan content defaults to Zstandard, Pro and Business to Brotli, and Enterprise to gzip. Toward the origin it requests br, gzip only, so precompressed origin responses are passed as Brotli or gzip.

What gzip compression level should I use?

Level 6 for dynamic compression. Level 9 took 1.5–1.9× as long in our test for at most a 2% gain, and was larger on one file. nginx defaults to level 1, which saves CPU at the cost of size.

How do I check which compression my site uses?

Open DevTools, select a request in the Network panel and look at the content-encoding response header. Or run the console snippet in this article to compare decodedBodySize with encodedBodySize for the page and its assets. Our curl to fetch converter helps turn a curl -H 'Accept-Encoding: zstd' check into browser code.


Benchmarks run on 4 December 2026 (Python 3.13.18, brotli 1.2.1, zstandard 0.25.0). Live encoding data from techloghub.com in Chrome 158 on the same day.

Stay Updated

Get the next deep dive in your inbox

Subscribe for product analysis, engineering explainers, and practical guides published on TechLogHub.

See what launched this week

One email a week: new and trending developer tools, fresh comparisons, and what shipped. Unsubscribe in one click.