RFC 7932 - Brotli Compressed Data Format
Published: July 2016
Status: Informational
Authors: J. Alakuijala (Google Inc.), Z. Szabadka (Google Inc.)
Abstract
This specification defines a lossless compressed data format that compresses data using a combination of the LZ77 algorithm and Huffman coding, with efficiency comparable to the best currently available general-purpose compression methods.
Status of This Memo
This document is not an Internet Standards Track specification; it is published for informational purposes.
This document is a product of the Internet Engineering Task Force (IETF). It has been approved for publication by the Internet Engineering Steering Group (IESG). Not all documents approved by the IESG are a candidate for any level of Internet Standard; see Section 2 of RFC 7841.
Information about the current status of this document, any errata, and how to provide feedback on it may be obtained at ````http://www.rfc-editor.org/info/rfc7932\````.
Table of Contents
-
- Introduction
- 1.1 Purpose
- 1.2 Intended Audience
- 1.3 Scope
- 1.4 Compliance
- 1.5 Definitions of Terms and Conventions Used
- 1.5.1 Packing into Bytes
-
- Compressed Representation Overview
-
- Compressed Representation of Prefix Codes
- 3.1 Introduction to Prefix Coding
- 3.2 Use of Prefix Coding in the Brotli Format
- 3.3 Alphabet Sizes
- 3.4 Simple Prefix Codes
- 3.5 Complex Prefix Codes
-
- Encoding of Distances
-
- Encoding of Literal Insertion Lengths and Copy Lengths
-
- Encoding of Block-Switch Commands
-
- Context Modeling
- 7.1 Context Modes and Context ID Lookup for Literals
- 7.2 Context ID for Distances
- 7.3 Encoding of the Context Map
-
- Static Dictionary
-
- Compressed Data Format
- 9.1 Format of the Stream Header
- 9.2 Format of the Meta-Block Header
- 9.3 Format of the Meta-Block Data
-
- Decoding Algorithm
-
- Considerations for Compressor Implementations
- 11.1 Trivial Compressor
- 11.2 Aligning Compressed Meta-Blocks to Byte Boundaries
- 11.3 Creating Self-Contained Parts within the Compressed Data
-
- Security Considerations
-
- IANA Considerations
-
- Informative References
Appendices
- Appendix A. Static Dictionary Data
- Appendix B. List of Word Transformations
- Appendix C. Computing CRC-32 Check Values
- Appendix D. Source Code
- Acknowledgments
- Authors' Addresses
Overview
What is Brotli?
Brotli is a generic-purpose lossless compression algorithm developed by Google in 2013. It is designed to compress data with compression ratios comparable to the best currently available general-purpose compression methods, while providing comparable decompression speeds.
Key Features
Technical Foundation:
- LZ77 algorithm variant (sliding window matching)
- Huffman coding (prefix encoding)
- Second-order context modeling
- Static dictionary (predefined common strings)
Performance Characteristics:
- Compression Ratio: 15-25% better than gzip
- Decompression Speed: Fast, comparable to gzip
- Compression Speed: Slower than gzip (adjustable by level)
- Window Size: 1 KB to 16 MB (configurable)
Typical Applications
1. HTTP Content Encoding
Accept-Encoding: br, gzip, deflate
Content-Encoding: br
Primary use cases:
- Static HTML/CSS/JavaScript files
- Web fonts (WOFF2 uses Brotli internally)
- API responses
2. Font Compression (WOFF2)
WOFF2 standard:
- Built-in Brotli compression
- Font files reduced by 30-50%
- Supported by all modern browsers
3. Offline Data Compression
Applications:
- Software package distribution
- Data archiving
- Android APK resources
Compression Levels
Level Ratio Speed Use Case
-----|----------|-----------|------------------
0 | Low | Very Fast | Real-time (not recommended)
1 | Low | Fast | Dynamic content
4 | Medium | Fast | Dynamic content (default)
5 | Good | Medium | Dynamic content
6 | Good | Slow | Static resources
9 | Very Good| Very Slow | Static resources
11 | Best | Slowest | Offline pre-compression
Recommendations:
- Dynamic content: Level 4-5
- Static pre-compression: Level 11
- Offline archiving: Level 11
Browser Support
Browser | Version | Support
----------------|---------|----------
Chrome | 50+ | ✓ Full
Firefox | 44+ | ✓ Full
Safari | 11+ | ✓ Full
Edge | 15+ | ✓ Full
Opera | 36+ | ✓ Full
IE | All | ✗ None
Mobile:
iOS Safari 11+: ✓
Android Chrome: ✓
Samsung Internet: ✓
Coverage: >95% of modern browsers
Brotli vs Gzip
Advantages:
- ✓ Better compression ratio (15-25% improvement)
- ✓ Fast or comparable decompression speed
- ✓ Especially suitable for text content
- ✓ Static dictionary improves HTML/CSS compression
Disadvantages:
- ✗ Slower compression speed
- ✗ Higher CPU usage
- ✗ Not suitable for real-time high-QPS scenarios
- ✗ No support in legacy browsers
Migration Strategy:
- Static resources: Use Brotli immediately
- Dynamic content: Evaluate before deciding
- High QPS: Keep gzip
- Low QPS: Can use Brotli
- Hybrid strategy:
- Static: Brotli pre-compression
- Dynamic: gzip real-time compression
- Fallback: Always provide gzip as backup
Related Resources
- Official RFC Text: RFC 7932 (TXT)
- Official Page: RFC 7932 DataTracker
- Brotli GitHub: ````https://github.com/google/brotli\````
- Related RFC: RFC 8878 - Zstandard Compression
- Errata: RFC Editor Errata
Summary: Brotli is a modern compression algorithm optimized for the Web, particularly suitable for pre-compressing static content. Through better compression ratios and fast decompression, it significantly improves Web performance and has become a standard component of the modern Web stack.