skillfed

brotlicffi

Python CFFI bindings to the Brotli library

brotlicffi v1.2.0.1 4.3M downloads/30d#2,350 on PyPI153
Permissive license MIT Active released

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 brotlicffi

uv

uv add brotlicffi

poetry

poetry add brotlicffi

Installing 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

Programming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Free Threading :: 2 - BetaProgramming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPy

Tags

brotli compression pythoncffi bindings compressionbrotli decompression librarystreaming compression pythonpypy brotli support
compressioncffipypy-compatible

More Utilities packages