Explainers · Explainer
What Is Brotli Compression? A Plain Explanation

Short answer
Brotli is a compression method that shrinks text files such as HTML, CSS, and JavaScript before a server sends them to a browser. It usually makes text files 14 to 21 percent smaller than gzip, thanks to a built-in dictionary of common web words. All modern browsers support it over HTTPS, and most CDNs and hosts switch it on for you.
Key takeaways
- Brotli shrinks text files before they are sent, and the browser unpacks them with nothing lost.
- Brotli is 14% smaller than gzip for JavaScript, 21% smaller for HTML, and 17% smaller for CSS.
- Brotli has 12 levels, from 0 to 11, and level 11 cut a test CSS file by 66.94%.
- Brotli only works over HTTPS and is supported in all modern browsers.
- Brotli does nothing useful for images, video, or audio, which are already compressed.
- Check the Content-Encoding header in developer tools: br means Brotli is working.
What is Brotli compression?
Brotli is a compression method that shrinks text files such as HTML, CSS, and JavaScript before a server sends them to a browser.
The name is short for “br”, which is the code browsers and servers use for it in HTTP headers. When a browser asks for a page, it lists the compression methods it understands, and the server picks the best one both sides support.
Brotli was built by Google and introduced in 2013. Cloudflare's blog notes that it supports higher compression levels and better performance overall than gzip, the older method from 1992 that it is slowly replacing.
The format is defined in RFC 7932, published by the IETF in July 2016. The RFC describes Brotli as a lossless compressed data format, which means the file comes back exactly as it was after the browser unpacks it.
How does Brotli work?
Brotli shrinks a file by finding repeated text and replacing it with shorter codes, then packing those codes into a smaller stream.
The format combines two older ideas: the LZ77 algorithm, which replaces repeats with short references, and Huffman coding, which gives short codes to the most common pieces. RFC 7932 states that the result is a compression ratio considerably better than the gzip program.
Brotli also ships with a built-in dictionary of common web words and phrases. That dictionary is why it beats gzip most clearly on HTML and CSS, where the same words, tags, and property names appear again and again.
The browser reverses the process when the file arrives. It reads the Content-Encoding: br header, unpacks the stream, and renders the page from the original text, with nothing lost.
How is Brotli different from gzip?
Brotli usually makes text files 14 to 21 percent smaller than gzip, because it uses a built-in dictionary of common web words.
Gzip uses the same two basic ideas, LZ77 and Huffman coding, but it has no dictionary. That single difference explains most of the gap: Brotli can replace a whole common word with a tiny code, while gzip must spell it out each time.
Brotli also has more levels to choose from. Cloudflare's blog explains that Brotli has 12 levels, from 0 to 11, where 0 is the fastest with the lowest ratio and 11 gives the highest ratio but needs more compute time. Gzip has only 9 levels.
The two methods are not rivals in practice. A server offers both, the browser picks Brotli when it can, and gzip stays as the fallback for older clients that do not send br in their request.
How much smaller are files with Brotli?
Brotli cuts a typical JavaScript file by about 76 percent from its raw size, and by about 14 percent compared with gzip.
Those figures come from a worked example in web.dev's Brotli codelab. A JavaScript bundle fell from 225 KB to 61.6 KB with gzip, then to 53.1 KB with Brotli. The pre-compressed Brotli file was about 76% smaller than the original.
The gain varies by file type. Web.dev cites figures from CertSimple: Brotli is 14% smaller than gzip for JavaScript, 21% smaller for HTML, and 17% smaller for CSS.
Cloudflare's own test shows the same pattern. On a 2,747-byte CSS file, Cloudflare's blog reports gzip at level 8 cut it to 1,121 bytes, while Brotli at level 11 cut it to 909 bytes. That is 19% smaller than the best gzip result.
| Method and level | Size of a 2,747-byte CSS file | Cut from the original |
|---|---|---|
| No compression | 2,747 bytes | 0% |
| Gzip level 8 | 1,121 bytes | 59.21% |
| Brotli level 4 | 1,110 bytes | 59.58% |
| Gzip level 9 | 1,121 bytes | 59.21% |
| Brotli level 11 | 909 bytes | 66.94% |
Do browsers and servers support Brotli?
All modern browsers support Brotli, but only over HTTPS, and your server or CDN must offer it for the browser to use it.
Web.dev states that Brotli is supported in all modern browsers, and that a server must support HTTPS to use it. Browsers that support Brotli include br in their Accept-Encoding headers, for example Accept-Encoding: gzip, deflate, br.
Cloudflare's blog notes that Brotli has been supported by browsers since 2016, and that Cloudflare has supported it since 2017 for the connection between Cloudflare and client browsers.
On the server side, support depends on your stack. Cloudflare's docs state that Cloudflare supports Gzip, Brotli, and Zstandard compression, and that it covers text types such as HTML, CSS, JavaScript, JSON, SVG, and fonts. Apache and Nginx can also serve Brotli with the right module loaded.
How do you turn on Brotli for WordPress?
You turn on Brotli in your hosting panel, your CDN settings, or a caching plugin, and most hosts now switch it on for you.
The simplest route is a CDN. Cloudflare's docs explain that Cloudflare compresses content for you, and that its default method is Zstandard on the Free plan, Brotli on Pro and Business plans, and Gzip on the Enterprise plan. You can change that default with a Compression Rule.
If your host runs LiteSpeed or Nginx with Brotli built in, the server may already send Brotli without any setting to change. Check with your host before you install a plugin to do the same job twice.
Caching plugins can also switch compression on, but they only help when the server itself supports the method. Our guide on how to enable gzip or Brotli compression in WordPress walks through the settings for the common stacks.
Our guide on how to set up a CDN for WordPress shows how to put Cloudflare in front of a site, which is the fastest way to get Brotli on a shared host.
What are the downsides of Brotli?
Brotli costs more server time than gzip at its highest levels, so it can slow a server that compresses every page on the fly.
Web.dev warns that compressing files at higher levels takes longer, and that this can cause a performance hit as the user waits for assets to compress before they are sent. That is why most servers use a middle level for pages built on each visit.
The fix is to compress static files once, ahead of time. Web.dev explains that with static compression, the files are already compressed when a visitor asks for them, so high levels cost nothing at request time, though build times grow.
Brotli also does nothing for files that are already compressed. Images, video, and audio are already packed tight, so running Brotli over them wastes CPU and can even make the file larger. Compression only pays off on text: HTML, CSS, JavaScript, JSON, SVG, and XML.
How do you check that Brotli is working?
Open your browser developer tools, load a page, and check that a text file shows br in its Content-Encoding header.
Web.dev explains that you can see which compression method was used in the Content-Encoding field of the Chrome Developer Tools Network tab. Open the Network tab, reload the page, click a JavaScript or CSS file, and look at its response headers.
If the header says br, Brotli is working. If it says gzip, the server fell back to gzip, which usually means the file type is not on the server's Brotli list or the browser did not offer br.
Also compare the transferred size with the file size. A JavaScript file that is 225 KB on disk but shows about 53 KB transferred is compressed well. Our guide on how to speed up WordPress shows how to read those numbers without fooling yourself with a single reading.
Our statistics guide on website speed statistics puts compression in context, with the latest figures on page weight and load times across the web.
Frequently asked questions
Is Brotli always better than gzip?
Yes, for text files. Brotli is 14% smaller than gzip for JavaScript, 21% smaller for HTML, and 17% smaller for CSS, based on figures web.dev cites from CertSimple. It does nothing useful for images, video, or audio, which are already compressed.
Does my site need HTTPS for Brotli to work?
No. Brotli only works over HTTPS, and the server or CDN must offer it. If either side does not support it, the browser falls back to gzip or to an uncompressed file, and the page still loads normally.
How do I check if Brotli is working on my site?
Open Chrome Developer Tools, go to the Network tab, reload the page, and click a JavaScript or CSS file. If the Content-Encoding response header says br, Brotli is working. If it says gzip, the server fell back to gzip.
Which Brotli level should I use?
Level 11 gives the smallest files but costs the most server time, so it suits files compressed once ahead of time. Level 4 is the middle ground Cloudflare used for years, and it suits pages compressed on each visit.
Should I compress images with Brotli too?
No. Compression only shrinks files that are mostly text, such as HTML, CSS, JavaScript, JSON, and SVG. Images, video, and audio are already packed tight, so running Brotli over them wastes CPU and can even make the file larger.
Sources
- RFC 7932: Brotli Compressed Data Format IETF
- Minify and Compress Network Payloads with Brotli web.dev
- All the Way Up to 11: Serve Brotli from Origin Cloudflare Blog
- Content Compression Cloudflare Developers
Is your product missing, or something out of date?
Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.
Thanks — we review requests within 3 business days.
Related guides
About the editors
Researched from the primary sources listed above and checked against our editorial rules before publishing.


