Text Compressor (gzip / deflate)

Compress arbitrary text in your browser using the native CompressionStream API. Pick gzip (most common), deflate (used by zlib), or raw deflate. See the exact byte count before and after, and download the compressed bytes as a binary file or copy as base64. Useful for estimating production page-weight savings, generating compressed payloads for testing, or producing pre-compressed assets to upload.

How to use the Text Compressor (gzip / deflate)

Paste text, click Compress. Pick the algorithm: gzip wraps deflate with a 10-byte header and CRC32 trailer (what HTTP's Content-Encoding: gzip uses); deflate wraps with a 2-byte zlib header and adler32 trailer; deflate-raw is just the deflate stream with no wrapper. For text content, all three achieve similar ratios; gzip is the most widely supported.

The stats line shows before/after byte count and the compression ratio. Real-world text compresses 60-80% (so ratio of 0.2-0.4); already-compressed data (JPEGs, .zip files re-encoded as text) compresses very little.

About Text Compressor (gzip / deflate)

The CompressionStream API exposes the browser's native compression to JavaScript — same engine that handles HTTP Content-Encoding, GZIP'd uploads, and most file format compression. It's available in every modern browser since 2022. Before this API existed, compressing in the browser meant shipping a JS compression library (pako, fflate); now it's built in and runs at native speed.

Why compress in the browser? Pre-compress assets for upload to a CDN; estimate the size of an API payload after gzip; build a chat client that compresses messages before sending; debug a server compression issue by comparing what the browser produces to what your server sends.

Common use cases

  • Size estimation — see how much smaller your API responses get after gzip.
  • Pre-compressing static assets — generate .gz versions to upload to a CDN that serves them directly.
  • Inline compression in a client app — compress text on the client before sending over a slow network.
  • Debugging — compare your server's compression output to the browser's reference implementation.

Frequently asked questions

Why not brotli?

Brotli is supported by Chrome for decompression, but only Firefox supports brotli compression via CompressionStream as of 2024. For server-generated brotli, you typically use a build tool or proxy.

How accurate is the size estimate?

Identical to what your server's gzip would produce — same algorithm, same parameters. Compression level may differ slightly (server-side gzip often uses a level setting; browser uses a fixed default).

Can I decompress with it too?

Yes — the browser also exposes DecompressionStream. This tool focuses on compression; pair with a decoder for round-trip testing.