Skip to main content

ZSTD vs Brotli vs GZip Comparison

· 9 min read
Kashish Kumawat
CEO @ SpeedVitals

Gzip vs Brotli vs Zstd

Brotli and GZip are two of the most popular compression algorithms for the web, and their browser support is exceptionally good. But we have a new player in town: ZSTD or Zstandard, which is developed by Facebook.

ZStandard adoption has increased significantly since 2024 when Cloudflare added support for the same. Now it is also available on Cloudflare's free plan and can be enabled using this compression rule. But is Zstandard worth using over Brotli and GZip? Let us find it out today!

While this article is written primarily keeping Web content in mind, we will also benchmark the compression ratios and times of large datasets in CSV and JSON formats.

Introduction

Before diving into the comparison, here's a brief history of all the algorithms:

GZip was first introduced in 1992 and has been around since the old days of the internet. It is based on the deflate algorithm and it is supported by almost every browser out there. Back in the day, even Internet Explorer and Netscape Navigator supported it. It offers a great balance of compression ratios, compression speeds, and decompression speeds.

Brotli was developed by Google in 2015 as a replacement for GZip for Web content. It uses LZ77, Huffman coding, and 2nd order context modelling. It offers the highest compression ratios among the three as it uses pre-defined static dictionaries for common web-related terms. It also has an excellent browser support of 95.9% as of June 2025. However, it has a slow compression speed, especially when working with large datasets. It is more ideal for static content than dynamic content.

ZStandard (ZSTD) was first introduced in 2015, but it has become more mainstream in recent years. It offers a similar or slightly better compression ratio compared to GZip, but it is exceptionally fast at compression and decompression speeds. It is ideal when the speed of compression/decompression is more important than the compression size. It is more of a general-purpose compression algorithm and not a replacement for Brotli for the Web. However, it can be considered a good replacement for GZip. It can also achieve higher compression ratios if required, but at the cost of compression speeds.

Here's a comparison table between the three algorithms:

GZipBrotliZstandard
Compression Ratio⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Compression Speed⭐⭐⭐⭐⭐⭐⭐
Decompression Speed⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
Browser Support⭐⭐⭐⭐⭐⭐⭐⭐

Performance Benchmarks

Let us do some compression ratio tests on different file types: HTML, Font, JavaScript, CSS, Image, JSON, and CSV.

Font File

We are using a TTF file format for this test. While it is not commonly used on the Web as WOFF or WOFF2 formats, we can better test compression ratios on these files compared to other formats that are already compressed.

ZSTDBrotliGZip
Compression Time0.01s0.82s0.02s
Decompression Time0.01s0.01s0.01s
Original Size307.31 KB307.31 KB307.31 KB
Compressed Size158.32 KB121.49 KB153.12 KB
Compression Percent48.5%60.5%50.2%

As you can see in the table, the compression ratio for Brotli was much higher compared to ZSTD and GZip. While the compression time wasn't impressive, it is a great option for static and cacheable content as it only required to be compressed once and can be served for days and weeks. In decompression, all three algorithms are equally fast.

HTML File

In case of HTML documents, we see a pretty similar story to the font files. ZSTD remains insanely fast while offering a great compression ratio.

Brotli takes the win for the compression percentage at the cost of higher compression time.

ZSTDBrotliGZip
Compression Time0.01s1.19s0.04s
Decompression Time0.01s0.01s0.01s
Original Size1,008.51 KB1,008.51 KB1,008.51 KB
Compressed Size209.70 KB160.44 KB213.55 KB
Compression Percent79.2%84.1%78.8%

JavaScript File

Once again, we see insanely fast compression times from ZSTD, with GZip not too far away. The compression time of Brotli has increased further as the file size has increased. Though it still reigns supreme as far as the file sizes are concerned.

ZSTDBrotliGZip
Compression Time0.01s1.80s0.05s
Decompression Time0.01s0.01s0.01s
Original Size1,588.08 KB1,588.08 KB1,588.08 KB
Compressed Size321.30 KB243.89 KB320.15 KB
Compression Percent79.8%84.6%79.8%

CSS File

Once again, we witness a similar story repeat in the case of an unminified CSS file. The compression percentage achieved by all three algorithms was impressive, and Brotli takes the edge again.

ZSTDBrotliGZip
Compression Time0.01s0.33s0.01s
Decompression Time0.01s0.01s0.01s
Original Size273.63 KB273.63 KB273.63 KB
Compressed Size36.48 KB23.87 KB32.70 KB
Compression Percent86.7%91.3%88.0%

Image File

We will be using a JPEG file for this test. As JPEG already uses a lossy compression, neither of the three managed to save any significant amount of size. But again, you should note that when the file size increased, the compression time crossed 3 seconds for Brotli.

ZSTDBrotliGZip
Compression Time0.01s3.13s0.08s
Decompression Time0.01s0.02s0.01s
Original Size3,016.68 KB3,016.68 KB3,016.68 KB
Compressed Size2,992.42 KB2,985.28 KB2,992.75 KB
Compression Percent0.8%1.0%0.8%

JSON File

Now, it is time to test a large JSON file that's over 500 MB. The issues with Brotli finally start to show up here. While ZSTD only takes half a second to compress this dataset by 81.68%, Brotli took 759 seconds to achieve a 87.8% compression. This makes Brotli an extremely poor choice for compressing large files. GZip achieved a similar compression ratio as ZSTD but took 10x time (which is still 133x faster than Brotli).

ZSTDBrotliGZip
Compression Time0.56s759.49s5.67s
Decompression Time0.57s1.09s0.78s
Original Size523.3 MB523.3 MB523.3 MB
Compressed Size95.8 MB63.6 MB95.5 MB
Compression Percent81.7%87.8%81.7%

CSV File

We take another large file in this test, and once again, Brotli took a very long time to compress this file. In fact, calling Brotli slow would be an understatement as ZSTD was 695 times faster than it. All the extra time taken cannot really justify the slightly better compression ratio.

ZSTDBrotliGZip
Compression Time0.83s576.73s11.4s
Decompression Time0.53s1.35s0.87s
Original Size349.4 MB349.4 MB349.4 MB
Compressed Size150.6 MB121.1 MB164.2 MB
Compression Percent56.9%65.3%53.0%

Browser Support

As per caniuse.com data as of June 2025, the Browser Support is as follows:

  • GZip: 100%
  • Brotli: 95.9%
  • ZSTD: 71.65%

ZSTD is currently supported in all major browsers except Safari. However, it is still safe to use it because when making an HTTP request, your browser sends the header "accept-encoding" which tells your Server/CDN about the supported encoding methods.

For example,

accept-encoding: gzip, deflate, br, zstd

would mean that the browser supports gzip, deflate, brotli, and zstd. Now your CDN/Server can choose to encode the data using any of these methods and add the following header in response:

content-encoding: zstd

This response header tells your browser how to decode the data.

In the case of Safari, the browser will not add zstd in the accept-encoding header, hence your CDN/Server will not serve zstd content and fall back to any other encoding method.

Thus, despite the lower browser support in ZSTD, you can still use it safely with the help of a fallback.

Conclusion

Based on the Performance Benchmarks, it seems ZSTD is the perfect choice when the Compression/Decompression times are of utmost importance, while Brotli takes the crown for Compression ratios. If you require both speed and good compression, ZSTD is the best choice.

The only time GZip can be preferred is when browser support and compatibility are a concern.

When it comes to large files in tens and hundreads of MBs or higher, Brotli is not recommended due to its extremely slow speeds. For large files, it may only be used for an extreme edge case where you require the least file size at the cost of high computing power and computing duration.

Summing up, here's your best choice:

  • For websites? → Brotli for static & cacheable content that has smaller file sizes, ZSTD for dynamic content of any size. Use ZSTD with fallback as it is not widely supported
  • For general-purpose compression? → ZSTD is the best mix of speed and efficiency
  • For maximum compatibility? → Stick with GZip as it is supported everywhere