Cette page est affichée en anglais. Une traduction française est en cours.
ScriptsJul 6, 2026·3 min de lecture

Brotli — Google's Modern Compression Algorithm for the Web

Brotli is a general-purpose lossless compression algorithm developed by Google that achieves higher compression ratios than gzip while maintaining fast decompression speeds. It is natively supported by all major browsers and web servers for HTTP content encoding.

Prêt pour agents

Installation agent prête

Cet actif peut être installé après choix du runtime, vérification du plan et exécution de la commande adaptée.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : Established
Point d'entrée
Brotli Overview
Commande d'installation directe
npx -y tokrepo@latest install efdf60eb-7978-11f1-9bc6-00163e2b0d79 --target codex

À exécuter après confirmation du plan en dry-run.

Introduction

Brotli is a lossless compression algorithm created by Google that combines a modern variant of the LZ77 algorithm with Huffman coding and context modeling. It is specified in RFC 7932 and has become the standard compression format for web content, supported as Content-Encoding: br in all major browsers since 2017.

What Brotli Does

  • Compresses static web assets (HTML, CSS, JavaScript) 15-25% smaller than gzip at comparable speeds
  • Provides 11 quality levels from fast (level 0) to maximum compression (level 11)
  • Decompresses faster than gzip at equivalent compression ratios, reducing client-side CPU cost
  • Includes a pre-built static dictionary of common web content patterns for better compression of small files
  • Supports streaming compression and decompression for real-time data processing

Architecture Overview

Brotli uses a sliding-window LZ77 variant combined with second-order context modeling and an entropy coder that switches between Huffman and prefix coding. A key innovation is its built-in 120KB static dictionary containing common strings found in HTML, CSS, JavaScript, and English text, which dramatically improves compression of small web resources. The algorithm operates in three modes: generic, UTF-8 text, and font data, each with optimized heuristics.

Self-Hosting & Configuration

  • Install via system packages: apt install brotli (Debian/Ubuntu) or brew install brotli (macOS)
  • Build from source with CMake: mkdir build && cd build && cmake .. && make
  • Nginx: enable with brotli on; brotli_types text/html text/css application/javascript;
  • Apache: enable with mod_brotli and AddOutputFilterByType BROTLI_COMPRESS
  • Language bindings available for Python (brotli), Node.js (iltorb), Java, and Rust

Key Features

  • RFC 7932 standard with universal browser support as Content-Encoding: br
  • Built-in static dictionary gives superior compression on small web assets compared to gzip
  • Quality levels 0-4 are faster than gzip with better ratios; levels 5-11 trade speed for compression
  • Reference implementation in pure C with no external dependencies
  • Decompression requires only 400KB of memory, making it suitable for embedded and mobile use

Comparison with Similar Tools

  • gzip/zlib — faster at compression but produces 15-25% larger output; Brotli is the modern replacement for web content
  • Zstandard (zstd) — faster compression at similar ratios, better for general data; Brotli wins on web assets due to its dictionary
  • LZ4 — optimized for speed over ratio; Brotli achieves much higher compression at the cost of speed
  • deflate — the algorithm inside gzip; Brotli adds context modeling and a static dictionary on top of similar LZ77 foundations
  • snappy — Google's speed-focused compressor; Brotli targets file size reduction rather than throughput

FAQ

Q: Should I use Brotli instead of gzip on my web server? A: Yes, for static assets. Pre-compress files at quality 11 for maximum savings. For dynamic content, use quality 4-6 to balance speed and ratio.

Q: Is Brotli supported by all browsers? A: All modern browsers (Chrome, Firefox, Safari, Edge) support Brotli via the Accept-Encoding: br header over HTTPS.

Q: How does Brotli compare to Zstandard? A: Zstandard is faster for general-purpose compression. Brotli excels at web content due to its built-in dictionary of HTML/CSS/JS patterns.

Q: Can I use Brotli for non-web data? A: Yes. The generic mode works on any data, though the static dictionary advantage applies mainly to web content.

Sources

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires