DevBolt
Processed in your browser. Your data never leaves your device.

How do I test Brotli vs Gzip compression online?

Paste text (JSON, HTML, CSS, or any content) and instantly see compression results for Brotli, Gzip, and Deflate side by side — compressed size, savings percentage, ratio, and compression time. The tool highlights the best algorithm. Everything runs in your browser using native CompressionStream and brotli-wasm.

Compare compression algorithms
Input
[JSON API response — 12.4 KB]
Output
Brotli:  2.1 KB (83% savings) ★ best
Gzip:    2.8 KB (77% savings)
Deflate: 2.9 KB (77% savings)

Brotli is 25% smaller than Gzip
Compression time: 3ms / 2ms / 1ms
← Back to tools

Brotli / Gzip Compression Tester

Test and compare Brotli, Gzip, and Deflate compression ratios for your text content. See which algorithm gives the best compression for your data.

About Compression Testing

  • Brotli — developed by Google, typically achieves 15-25% better compression than Gzip for text content. Supported by all modern browsers via HTTPS.
  • Gzip — the most widely supported compression format. Based on DEFLATE algorithm. Universally supported by web servers and browsers.
  • Deflate — the underlying algorithm used by both Gzip and Zlib. Lower overhead than Gzip (no header/trailer), but less common as a standalone format.
  • Compression ratios vary by content type — repetitive text like JSON and HTML compresses well (70-90% savings), while already-compressed or random data may not compress at all.
  • Everything runs in your browser — Gzip and Deflate use the native CompressionStream API, Brotli uses brotli-wasm. No data is sent over the network.

Tips & Best Practices

Pro Tip

Brotli compresses 15-25% better than Gzip for text content

Brotli consistently beats Gzip on HTML, CSS, JavaScript, and JSON. The tradeoff: Brotli compression is slower (use static pre-compression for assets) but decompression is equally fast. All modern browsers support Brotli via the br content-encoding.

Common Pitfall

Don't compress already-compressed formats like JPEG, PNG, or MP4

Images, videos, and most binary formats are already compressed. Running them through Gzip or Brotli wastes CPU and can actually increase file size due to compression headers. Only compress text-based formats and uncompressed data.

Real-World Example

Pre-compress static assets at build time with maximum compression

Brotli level 11 compresses 50% better than level 1 but takes 100x longer. For static assets (JS, CSS), compress once at build time with maximum quality. For dynamic responses, use Brotli level 4-6 for a good speed/ratio tradeoff.

Security Note

Be aware of BREACH attacks when compressing HTTP responses

The BREACH attack exploits HTTP compression to extract secrets like CSRF tokens by measuring response sizes. Mitigations include: don't reflect user input and secrets on the same page, add random padding to responses, or use per-request CSRF tokens.

Frequently Asked Questions

What is the difference between Brotli, Gzip, and Deflate compression?
Brotli, Gzip, and Deflate are HTTP compression algorithms that reduce file transfer sizes. Deflate is the oldest algorithm using LZ77 and Huffman coding. Gzip wraps Deflate with a header and checksum, and has been the web standard since the 1990s. Brotli, developed by Google, uses a larger sliding window, context modeling, and a static dictionary of common web strings, achieving 15-25% better compression than Gzip on typical web assets. DevBolt's Compression Tester lets you compare all three algorithms side by side on your actual content, showing compressed sizes and ratios instantly in your browser. All compression runs client-side.
How much smaller will Brotli make my JavaScript and CSS files?
Brotli typically compresses JavaScript files 15-25% smaller than Gzip and CSS files 10-20% smaller at comparable compression levels. For example, a 100KB JavaScript bundle might compress to 30KB with Gzip but only 24KB with Brotli. The improvement comes from Brotli's built-in dictionary of common web strings like HTML tags, CSS properties, and JavaScript keywords. The actual savings depend on your content. Repetitive code with common patterns compresses better. Paste your actual files into DevBolt's Compression Tester to see exact before-and-after sizes for all three algorithms compared on your specific content.
Should I use Brotli or Gzip for my web server?
Use Brotli for static assets and Gzip as a fallback. Brotli achieves better compression ratios but is slower to compress at high quality levels, making it ideal for pre-compressed static files served from CDNs. Gzip is faster to compress on the fly, better suited for dynamic content generated per request. Most CDNs including Cloudflare, AWS CloudFront, Vercel, and Netlify support Brotli automatically. Browser support exceeds 97% globally. Configure your server to serve Brotli when the client sends Accept-Encoding: br, falling back to Gzip for older clients. Pre-compress static assets with Brotli at level 11 during build time for maximum performance.

Related Inspect Tools