Gzip Compress / Decompress
Compress text or any file with gzip, zlib or raw deflate and get the result as Base64, hex or a .gz download. Paste a Base64 or hex gzip string, or drop a .gz file, to decompress it. Everything runs in your browser with the built-in CompressionStream API.
Last updated:
Stream details
How to use the Gzip Compress / Decompress
- Choose Compress or Decompress and whether you are working with text or a file.
- Pick the format: gzip for .gz files and HTTP, zlib for many APIs and PNG-style streams, raw deflate for ZIP entries and some web APIs. Decompress can auto-detect it.
- Enter the data: type or paste text, paste a Base64 or hex string, or drop a file.
- Read the stats to see how much smaller the data got, and the gzip header details when decompressing.
- Copy or download the result: Base64 or hex text, a .gz file, or the decompressed file.
gzip vs zlib vs raw deflate
All three wrap the same DEFLATE compressed data (LZ77 plus Huffman coding, RFC 1951). They differ only in the header and checksum around it, so pick the one the receiving program expects:
| Format | Header | Trailer | Starts with | Typical use |
|---|---|---|---|---|
| gzip (RFC 1952) | 10 bytes + optional name, comment | CRC-32 + original size (8 bytes) | 1F 8B · Base64 H4sI | .gz and .tgz files, HTTP Content-Encoding: gzip |
| zlib (RFC 1950) | 2 bytes | Adler-32 (4 bytes) | 78 9C, 78 01, 78 DA · Base64 eJ | PNG chunks, PDF streams, Python zlib, HTTP deflate |
| raw deflate (RFC 1951) | none | none | no fixed signature | ZIP entries, WebSocket permessage-deflate, some APIs |
Reading the compression stats
- Ratio = compressed size ÷ original size × 100. 25% means the output is a quarter of the input.
- Space saved = 100% − ratio.
- Factor = original size ÷ compressed size, for example 4.00 : 1.
- As Base64 shows the text length you would store or send: 4 × ⌈compressed bytes ÷ 3⌉ characters. Gzip plus Base64 only pays off when compression saves more than about 25%.
Equivalent commands
To reproduce or check results on the command line:
- Compress to Base64:
gzip -c file.txt | base64 - Decompress Base64:
echo 'H4sI…' | base64 -d | gunzip - Python:
gzip.compress(data),zlib.compress(data), orzlib.compressobj(wbits=-15)for raw deflate - JavaScript: pipe
blob.stream()throughnew CompressionStream('gzip')and read it withnew Response(stream).arrayBuffer()
Frequently asked questions
How do I decompress a gzip Base64 string?
Choose Decompress, keep the input on Text and paste the Base64 string. The tool decodes the Base64, recognises the gzip header (it starts with H4sI in Base64, which is the bytes 1F 8B), inflates it and shows the text. If the result is binary, use the download button to save it as a file.
What is the difference between gzip, zlib and deflate?
All three use the same DEFLATE compression algorithm (RFC 1951). Raw deflate is the bare compressed stream. Zlib (RFC 1950) adds a 2-byte header and an Adler-32 checksum. Gzip (RFC 1952) adds a 10-byte header with optional file name and timestamp, plus a CRC-32 and the original size at the end. The compressed data inside is identical.
Why is my compressed output bigger than the input?
Gzip adds about 18 bytes of header and trailer, and very short or random data has no repetition to remove. Text under roughly 100 bytes, already compressed files such as JPEG, MP4 or ZIP, and encrypted data usually do not shrink. Base64 then adds another 33% because it uses 4 characters per 3 bytes.
How much does gzip compress text?
It depends on how repetitive the data is. Typical HTML, CSS, JavaScript and JSON shrink to about 15% to 30% of their size, plain English prose to about 35% to 45%. The stats panel shows the exact ratio for your data.
What do the compression levels do?
Level 1 is fastest with larger output, level 9 tries hardest for the smallest output, and 6 is the gzip default. The browser's native CompressionStream does not let you choose a level, so selecting a number loads the small pako library to compress instead. Any level can be decompressed by any gzip tool.
Why does decompression fail with an error?
Common causes are a Base64 string that was cut off or wrapped with extra characters, data that is actually a ZIP archive (starting with PK, use an unzip tool instead), the wrong format selected (try Auto-detect), or a stream that is not compressed at all. The tool shows the first bytes it found to help you check.
Is my data uploaded?
No. Compression and decompression use your browser's CompressionStream and DecompressionStream APIs (or the pako library for levels), so text and files stay on your device.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.