brotlicffi
Python CFFI bindings to the Brotli library
What it is and what it does
BrotliCFFI is a Python wrapper around the Brotli compression algorithm, implemented using CFFI (C Foreign Function Interface) rather than C extensions. It provides both one-shot compression/decompression functions and streaming APIs for incremental processing. The package is designed as a drop-in alternative to the native Brotli C bindings, with identical API compatibility, making it particularly useful for PyPy and other non-CPython implementations where C extensions are impractical.
The library depends only on cffi and wraps the reference Brotli encoder/decoder from Google. It supports modern Python versions (3.8 through 3.14, including free-threaded builds) and multiple platforms. Recent versions include security-focused features like output buffer limits to mitigate decompression bombs, and explicit exception handling for concurrent access to compressor/decompressor objects.
Use it for:
- Decompress Brotli-encoded HTTP responses in web clients or servers running PyPy or alternative Python implementations.
- Streaming compression of large files or network data using the Compressor/Decompressor classes with incremental processing.
- Cross-implementation Python projects that need Brotli support on both CPython and PyPy using conditional dependencies.
- Protect against maliciously crafted compressed data by setting output_buffer_limit on decompression operations.
- Build HTTP middleware or reverse proxies that handle Brotli content encoding on platforms where C extensions are unavailable.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides Python CFFI bindings to the Brotli compression library, enabling Brotli compression and decompression from Python code with an API compatible with the C bindings.
Yes, if you need Brotli compression on PyPy or other non-CPython implementations, or if you prefer CFFI-based bindings over C extensions. On CPython, the native Brotli package is typically preferred for performance, but this package is a solid alternative with active maintenance, no known vulnerabilities, and permissive licensing. Install friction is moderate but manageable with pre-built wheels for common platforms.
Install
brotlicffi on PyPI
pip
pip install brotlicffiuv
uv add brotlicffipoetry
poetry add brotlicffiInstalling brotlicffi
Before you install
Medium install friction due to compiled wheels; pre-built binaries available for common platforms (CPython 3.8+, PyPy 3.11) and architectures (x86_64, aarch64, ARM, Windows). Actively maintained with recent release (162 days old) and ongoing repository activity.
License in practice
MIT license on the Python bindings themselves; the underlying Brotli library is Apache 2.0. Both are permissive, allowing commercial and private use without restriction.
Quickstart
pip install brotlicffi
import brotlicffi
data = brotlicffi.decompress(compressed_data)
Requires Python 3.8 or later; PyPy support available via CFFI bindings as an alternative to the C implementation.
Verify before relying
- Whether the output_buffer_limit parameter (added in 1.2.0.0) is documented and how to use it effectively for security.
- Performance characteristics compared to the native Brotli C bindings on CPython.
- Thread safety guarantees beyond the documented exception for concurrent Compressor/Decompressor sharing.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — cffi |
| Maintenance | actively maintained — 162 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,252,364/month — #2,350 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: brotlicffi-1.2.0.1-cp314-cp314t-macosx_11_0_arm64.whl; brotlicffi-1.2.0.1-cp314-cp314t-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; brotlicffi-1.2.0.1-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; brotlicffi-1.2.0.1-cp314-cp314t-win32.whl; brotlicffi-1.2.0.1-cp314-cp314t-win_amd64.whl; brotlicffi-1.2.0.1-cp38-abi3-macosx_11_0_arm64.whl; brotlicffi-1.2.0.1-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; brotlicffi-1.2.0.1-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; brotlicffi-1.2.0.1-cp38-abi3-win32.whl; brotlicffi-1.2.0.1-cp38-abi3-win_amd64.whl; brotlicffi-1.2.0.1-pp311-pypy311_pp73-macosx_11_0_arm64.whl; brotlicffi-1.2.0.1-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; brotlicffi-1.2.0.1-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; brotlicffi-1.2.0.1-pp311-pypy311_pp73-win_amd64.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
brotlipybrotlipy provides Python bindings to the Brotli…
permissive · top 5,000 on PyPI
brotliProvides Python bindings to the Brotli…
permissive · top 1,000 on PyPI
brotli-asgiBrotliMiddleware adds Brotli compression to…
permissive · top 15,000 on PyPI
lzfsePython bindings for the LZFSE reference…
permissive · top 5,000 on PyPI
python-neo-lzfProvides fast compression and decompression of…
permissive · top 15,000 on PyPI
cramjamProvides fast Python bindings to multiple…
permissive · top 1,000 on PyPI
inflate64Provides Deflater and Inflater classes to…
copyleft · top 5,000 on PyPI
unlzw3Decompresses .Z files (Unix compress format)…
permissive · top 15,000 on PyPI
onigurumacffiProvides Python bindings to the Oniguruma regex…
permissive · top 15,000 on PyPI
cffiCFFI enables Python code to call C functions…
permissive · top 100 on PyPI