Brotli
See what Brotli does beyond gzip: a built-in dictionary of common words, a larger window, and quality levels that trade time for size.
- Window: up to 16 MB
- Dictionary: 122 KB
- Quality: 0-11
- Codes depend on context
What do these mean?
- Built-in dictionary: about 13,500 words that every Brotli decoder knows, so the encoder can refer to one by its number.
- Quality: Brotli's effort setting from 0 to 11. Higher levels search harder for a few percent less, at many times the cost.
- Context modelling: choosing the code table by what came just before, since different characters follow a letter than a digit or a space.
- Window: how far back the compressor may look for a repeat. 32 KB in gzip, up to 16 MB in Brotli.
Words from the Brotli dictionary
Paste any text. The words Brotli's dictionary holds are marked, and the bars compare the first 300 bytes, where the dictionary matters most, with the whole text.
Loading...
Try this: Load a short HTML page. On a few hundred bytes the dictionary decides the result, and Brotli pulls well ahead of gzip.
Quality, size and time
The same text at every quality. Up to 4-6 the size drops fast while the time barely moves; 10 and 11 buy a few percent more for many times the work.
Loading...
How it differs from gzip
A window of up to 16 MB
gzip copies only from the last 32 KB. Brotli reaches much further, so in a large file it finds repeats gzip can no longer see.
Codes that depend on context
The same character can get a different code depending on the two bytes before it. Different characters are likely after a letter than after a digit or a space.
A dictionary from the start
gzip has to write the first appearance of every word as literals. Brotli can refer to its built-in dictionary instead, which is why it gains most on small files.
How it works
Brotli uses the same two ideas as gzip, copies of earlier text and Huffman codes, and adds three. Its window reaches 16 MB instead of 32 KB, so it finds repeats far back in a large file. Its codes depend on the context of the previous bytes. And it ships a dictionary of about 13,500 words common in web pages and code, so even the first appearance of a word like class or function can be a short reference.
When it is a good choice
Brotli makes text 15-25% smaller than gzip, most of all on small files where the dictionary does the work. Every current browser accepts it over HTTPS. Compress static files ahead of time at quality 11 and dynamic responses on the fly at 4-6, where it is about as fast as gzip.