ShrinkRay All Articles
Developer Productivity

Zstd, Brotli, or Gzip? A 2026 Field Guide for Picking Compression by Asset

By ShrinkRay Developer Productivity
Zstd, Brotli, or Gzip? A 2026 Field Guide for Picking Compression by Asset

Photo: MuthuKutty at English Wikipedia, CC BY-SA 3.0, via Wikimedia Commons

Compression debates have a way of turning into religious wars. Gzip is the reliable old friend. Brotli is the web-performance favorite. Zstd is the fast, modern upstart that keeps showing up in build pipelines and log storage. None of them is universally best. The right pick depends on whether you are serving HTML to a browser, archiving logs for a year, dumping a database, or shipping a build artifact to another service.

This is not a benchmark contest. It is an operations guide. The goal is to pick a default per asset type, document it, and stop burning time re-litigating the same choice every quarter.

The short version

Use Brotli for static web text assets where you can precompress at high quality. Use Gzip as the universal fallback for browsers and old clients. Use Zstd for internal data, logs, archives, build artifacts, and anything where decompression speed and ratio both matter. Do not compress already-compressed media. And measure before you turn on maximum settings everywhere, because CPU is not free.

How the three differ

Gzip is built on DEFLATE. It is everywhere, it is fast enough, and every browser and HTTP client speaks it. Its ratio is decent for text but not spectacular. Brotli uses a different algorithm plus a built-in dictionary tuned for web content. It usually beats Gzip on HTML, CSS, and JavaScript, especially at higher quality settings. The catch is that high-quality Brotli can be slow to compress, which is why static precompression is the sweet spot. Zstd is designed for a wide range of speed/ratio tradeoffs. It compresses fast, decompresses very fast, and supports dictionaries and long-range matching. It is excellent for logs, database dumps, and build caches. Browser support for Zstd as an HTTP content encoding is better than it used to be but still uneven in 2026, so verify your traffic before making it your only web compression path.

Ratio: good enough is good enough

People love to compare compression ratios to two decimal places. In production, the difference between 72% and 75% savings is usually less important than whether the CPU bill doubles. Brotli at maximum quality can squeeze out extra bytes from a JavaScript bundle, but if you are compressing on every request, that setting may cost more than the bandwidth it saves. Precompress static assets once, serve the result, and keep dynamic compression at a sane level.

Zstd often lands in a pleasant middle: ratios close to Brotli on many datasets, with much faster decompression and competitive compression speed. For logs and internal APIs, that combination is hard to beat. For browser-facing HTML, Brotli still has the edge because of its dictionary and broad support.

Speed: the bill arrives at scale

Compression speed matters when you are doing it thousands of times per second. Decompression speed matters when clients or workers are reading the data. Gzip is the baseline. Brotli compression can be slow at high quality, but decompression is generally fine. Zstd decompression is very fast, which is why it shows up in databases, log pipelines, and package formats.

The practical rule: compress once at high quality for static assets, compress dynamically at a level your CPU budget can tolerate, and benchmark with your actual payloads. A synthetic 10 MB text file is not the same as your real JSON response with lots of short keys and repeated IDs.

Browser support: do not ship Zstd to the browser without a plan

Gzip is universal. Brotli is supported by all modern browsers over HTTPS. Zstd support as a Content-Encoding is improving but not something you should assume for every user in 2026. If you want Zstd on the web, use content negotiation and keep Brotli and Gzip as fallbacks. For internal services, browser support is irrelevant, so Zstd becomes much more attractive.

Decision table

Asset type Default pick Why
HTML, CSS, JS Brotli, precompressed at high quality Best ratio for web text; serve static files
JSON API responses Brotli or Gzip dynamically; Zstd for internal Balance CPU and bytes; test your payloads
Logs Zstd Fast compression and decompression; good ratio
Database dumps Zstd Strong ratio with fast restore speed
Build artifacts Zstd Great for caches and package transfer
Images, video, fonts Do not recompress Already compressed; use format optimization instead
Small responses under 1 KB Probably skip compression Headers and CPU can outweigh savings
Legacy clients Gzip Universal fallback

Operational notes

Precompress static assets at build time. Store the Brotli and Gzip versions next to the original, and let your web server or CDN negotiate. For dynamic responses, set a minimum size threshold so you are not compressing 300-byte error messages. Check your CDN’s supported encodings before you promise Brotli to every client. If you run Zstd internally, standardize the compression level per workload so your benchmarks mean something.

Also watch the interaction with encryption and signed URLs. Compression happens before encryption, and some CDNs will not compress certain content types. Test the full path, not just the library benchmark.

Pick by asset, not by fashion

The boring answer is usually the right one. Brotli for static web text. Gzip for compatibility. Zstd for logs, dumps, archives, and internal pipelines. Do not compress media that is already compressed. Measure the CPU cost. Write down the policy. Then spend your time on something more interesting than arguing about compression levels in a pull request.

ShrinkRay’s angle is the same as ever: waste nothing, but do not optimize blindly. The best algorithm is the one that fits the asset, the client, and the bill.