Skip to content
gohacks.dev
Performance

Gzip Compress and Decompress

Compress text with gzip, zlib or raw deflate and see the ratio, or decompress Base64-encoded compressed data back to text, using the browser's CompressionStream.

Free · No sign-up · Your inputs stay in your browser

Input

Gzip or deflate text

Output

Base64 of the compressed bytes

Uses the browser's CompressionStream. gzip is what Content-Encoding: gzip and .gz files carry; 'deflate' in HTTP actually means zlib, and PHP's gzdeflate() writes raw deflate, gzcompress() zlib and gzencode() gzip. Repetitive text like JSON logs shrinks most.

Runs in this browser. Nothing you paste is sent to a server.

Three wrappers, one algorithm

All three use the DEFLATE algorithm of RFC 1951. Raw deflate is the bare stream; zlib (RFC 1950) adds a two-byte header and an Adler-32 checksum; gzip (RFC 1952) adds a longer header and a CRC-32. HTTP's Content-Encoding: deflate means zlib, despite the name.

PHP's three functions

gzdeflate() writes raw deflate, gzcompress() zlib and gzencode() gzip, with gzinflate(), gzuncompress() and gzdecode() to reverse them. Data compressed by one cannot be read by the wrong inverse, which is the usual reason decompression fails.

Share

Frequently asked questions

Why can't I decompress my data?
It may be a different format: try gzip, zlib and raw deflate in turn. Base64 that was URL-safe or had line breaks is accepted; a truncated payload is not.
How much will gzip shrink my JSON?
Repetitive text such as JSON and logs often shrinks by 70 to 90 percent. Already-compressed data such as JPEG or ZIP does not shrink at all.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools