Brotli Compress

Encoders & Decoders

How to use the Brotli Compress

Compress text with Brotli in three steps:

1

Paste text and select quality

Paste any text or click 'Load Sample'. Choose a quality from 0 (fastest, highest output size) to 11 (slowest, smallest output). Quality 6 is the default balanced setting.

2

Click Brotli Compress

The WASM module compresses the text instantly and shows the compression statistics — original size, compressed size, savings percentage, and a visual bar chart.

3

Copy or download

Select Base64 or Hex as the output format for text transport. Click Copy to copy the encoded string, or download the raw .br binary file for server deployment.


When to use this tool

Use the Brotli Compressor when you need maximum compression for web-optimised text payloads:

  • Compressing HTML, CSS, and JavaScript responses for web servers that support Content-Encoding: br to reduce page load times
  • Pre-compressing JSON API payloads or configuration files that are repeatedly served and benefit from Brotli's higher compression ratio vs gzip
  • Comparing Brotli vs gzip compression ratios on your actual content to decide which algorithm to enable on your CDN or reverse proxy
  • Generating .br pre-compressed files for static asset serving (nginx, Caddy) so the server can skip runtime compression
  • Compressing log files or text exports before storing them in object storage (S3, GCS) to reduce storage costs
  • Debugging Content-Encoding: br responses by compressing a sample payload and verifying the output matches what your server sends

Frequently asked questions

Q:How does Brotli compression compare to gzip?
Brotli (developed by Google, RFC 7932) typically achieves 15–25% better compression ratios than gzip on web content like HTML, CSS, JavaScript, and JSON. Brotli uses a combination of LZ77 backward references, Huffman coding, and a context-modelling technique that exploits second-order letter probabilities in natural language and code. At quality 11, Brotli can be significantly slower than gzip level 9, but quality 6 (the default) is fast while still beating gzip. All major browsers support Content-Encoding: br, and most CDNs and modern web servers (nginx 1.11.5+, Caddy, Cloudflare) support Brotli encoding.
Q:What does quality 11 mean and when should I use it?
Quality 11 is the maximum Brotli compression level — it enables the most aggressive context modelling and produces the smallest possible output at the cost of the longest compression time. Quality 11 is most appropriate for static assets that are compressed once at build time and served many times (images, JS bundles, CSS). For dynamically compressed HTTP responses where latency matters, quality 4–6 gives good compression at much faster speeds. Quality 0 is the fastest setting, useful when you need any compression but cannot afford CPU time — it still typically outperforms no compression on repetitive content.
Q:Why is the output encoded as Base64 or hex instead of binary?
Brotli compressed data is binary — it contains arbitrary byte values from 0x00 to 0xFF. Binary data cannot be safely transmitted or displayed in contexts that expect text (terminal output, JSON strings, URLs, form fields, clipboard). Base64 encoding adds ~33% overhead but produces a safe ASCII string that can go anywhere text is accepted. Hex encoding adds 100% overhead but is essential when you need to embed compressed data in C arrays, SQL literals, or log files that use hex notation. For server deployment, download the .br binary directly — that file can be used with nginx/Caddy without any encoding overhead.
Q:How does this tool run Brotli in the browser without a server?
This tool uses brotli-wasm — a WebAssembly (WASM) compilation of the official Google Brotli C library. WebAssembly runs a compiled binary directly in the browser at near-native speed. The WASM module is loaded asynchronously on first use (shown by the loading banner) and then cached. Compression happens entirely in the JavaScript runtime inside your browser tab — your input text is never transmitted to any external server, making this tool safe for compressing sensitive or proprietary content.
Q:What type of content benefits most from Brotli compression?
Brotli is most effective on structured, text-based content with repetition: HTML (30–40% savings vs uncompressed), CSS (50–70%), JavaScript (50–65%), JSON APIs (40–60%), SVG (40–60%), and log files with repeated patterns (50–80%). Binary formats like PNG, JPEG, and MP4 are already compressed internally and will see minimal or negative savings (Brotli adds header overhead). Very short strings under 50 bytes may actually become larger after compression due to the algorithm's fixed-overhead headers. The compression analysis panel shows exact savings for your specific input.
Q:Can I use the .br output file directly with nginx or Caddy?
Yes — download the .br binary file and place it alongside the original file on your web server. For nginx, enable ngx_http_brotli_static_module and configure brotli_static on; in your location block — nginx will then automatically serve the .br file when clients send Accept-Encoding: br. For Caddy, use encode brotli in your Caddyfile. For Apache, use mod_brotli or serve pre-compressed files via content negotiation. The .br file must be generated from the same content the server would normally serve — use quality 11 for maximum compression of static assets that rarely change.