explaingit

google/brotli

Analysis updated 2026-06-24

14,699TypeScriptAudience · developerComplexity · 3/5LicenseSetup · easy

TLDR

Google's Brotli compression library and reference encoder, combining LZ77, Huffman coding, and context modeling to produce smaller output than gzip at similar speed. Documented as RFC 7932.

Mindmap

mindmap
  root((brotli))
    Inputs
      Raw bytes
      Compression level
    Outputs
      Compressed stream
      Decompressed bytes
    Use Cases
      Web asset compression
      HTTP responses
      Static file pipelines
      Embedded storage
    Tech Stack
      C
      CMake
      Bazel
      Python
      JavaScript
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Compress static web assets at build time for smaller bundle sizes than gzip

USE CASE 2

Add Brotli encoding to an HTTP server or CDN edge worker

USE CASE 3

Compress logs or telemetry batches before upload from an embedded device

USE CASE 4

Wrap libbrotli in a custom CLI for batch compressing artifact directories

What is it built with?

CPythonCMakeBazel

How does it compare?

google/brotliajv-validator/ajvformatjs/formatjs
Stars14,69914,70514,708
LanguageTypeScriptTypeScriptTypeScript
Setup difficultyeasyeasymoderate
Complexity3/52/53/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

The format has no built in checksum or original size record, so apps that need tamper detection must add their own integrity layer.

MIT license: you can use, change, ship, and sell it as long as you keep the copyright notice.

In plain English

Brotli is a compression algorithm developed at Google. Compression algorithms take a file, find patterns and repetitions, and rewrite the data in a shorter form that can be expanded back later without losing anything. The README says Brotli mixes a modern version of an older technique called LZ77 with Huffman coding and second-order context modeling, all of which are standard ideas in the compression field. The practical claim in the README is that Brotli runs at speeds similar to deflate, the algorithm behind gzip and zip files, but produces smaller output. The Brotli data format is published as an open standard called RFC 7932, so anyone can write their own encoder or decoder against the same spec. The project is released under the MIT license. There is a warning in the README worth noting for builders: Brotli is a stream format. It does not include checksums or a record of the original size. That means the compressed bytes will decode without error even if someone modifies parts of them, so applications that need to detect tampering have to add their own checks on top. Installation is covered for several environments. On Debian-based Linux you can run apt install brotli, and on macOS you can run brew install brotli. For C and C++ users there are build instructions using vcpkg, Bazel, and CMake. There is also a Python module that you install with pip install brotli, with a separate readme inside the python directory for development details. The README ends with pointers for getting help and a list of benchmarks, including the Squash Compression Benchmark and the Large Text Compression Benchmark, where Brotli can be compared with other algorithms. It also lists third-party ports the authors do not maintain, including an independent decoder by Mark Adler, a JavaScript port, a Haxe port that outputs JavaScript, PHP, Python, Java and C# code, a 7Zip plugin, and a Dart wrapper. These ports let projects in many languages read and write the Brotli format.

Copy-paste prompts

Prompt 1
Install brotli on Ubuntu and compare its output size to gzip on a 10MB JSON file
Prompt 2
Use the Python brotli module to compress and decompress a stream chunk by chunk
Prompt 3
Build libbrotli from source with CMake and link it into a small C program
Prompt 4
Configure Nginx to serve Brotli precompressed assets falling back to gzip
Prompt 5
Generate a test that verifies a tampered Brotli stream still decodes since the format has no checksum

Frequently asked questions

What is brotli?

Google's Brotli compression library and reference encoder, combining LZ77, Huffman coding, and context modeling to produce smaller output than gzip at similar speed. Documented as RFC 7932.

What language is brotli written in?

Mainly TypeScript. The stack also includes C, Python, CMake.

What license does brotli use?

MIT license: you can use, change, ship, and sell it as long as you keep the copyright notice.

How hard is brotli to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is brotli for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.