Gzip Compressor & Decompressor
Compress and decompress text with gzip, deflate, or deflate-raw
About
Compress text into gzip, deflate, or deflate-raw and decompress it back, using the browser's native CompressionStream/DecompressionStream. Output is base64-encoded and the compressed size and ratio are shown. Everything runs locally; nothing is uploaded.
Examples
Compress text to gzip
text: The quick brown fox jumps over the lazy dog.H4sIAAAAAAAAA3PP0sivyCxIVAguLilK5XBkBQAQ/wb/EAAAAA== (gzip, base64)
Compressed: 52 bytes (original: 45 bytes, 85% of original)Short text often compresses poorly or grows due to the gzip header. Longer, repetitive text achieves significant savings.
Decompress a gzip stream
H4sIAAAAAAAAA3PP0sivyCxIVAguLilK5XBkBQAQ/wb/EAAAAA==The quick brown fox jumps over the lazy dog.The base64-encoded gzip stream is decoded, decompressed, and the original text is recovered losslessly.
About this tool
This tool compresses plain text and decompresses Base64 back to text using the codecs built into your browser — nothing is uploaded. All three offered formats carry the same DEFLATE bitstream but differ in framing: gzip adds a file header (starting with the 1f 8b magic bytes) plus a CRC-32 trailer, deflate wraps the stream in a short zlib header with an Adler-32 checksum, and deflate-raw is the bare stream with no wrapper at all.
Results are returned as Base64 with the compressed byte count and the ratio against the original. Repetitive text shrinks dramatically — the sample payload shows it — while short or already-random input can grow: headers and checksums outweigh the bytes saved, and the badge then shows a plus percentage. Compression also estimates what Brotli and Zstandard would produce.
It is the same gzip web servers apply as Content-Encoding: gzip, which curl --compressed unpacks transparently — so this Base64 behaves like a .gz payload sent through an API.
How to use this tool
Pick a direction and format
Compress turns text into Base64; Decompress expects Base64 data in the format you select.
Paste the input
Any text to compress, or a Base64 string such as a gzip payload from an API to decompress.
Run it
The output appears with compressed byte count and ratio, plus Brotli/Zstandard size estimates when compressing.
Copy the result
Take the Base64 or the recovered text; keep the format consistent and the pair round-trips.
Use cases
Testing gzip compression in a pipeline
Paste a text payload, compress it to gzip, and send it to a server that accepts gzip-encoded request bodies to test compression handling.
Inspecting compressed log files
Decompress a gzip log file stored in a text editor or data tool that doesn't natively read .gz files.
Estimating bandwidth savings
Compress a JSON response body and see the size ratio to estimate how much bandwidth gzip would save in a real HTTP transaction.
The three formats
| Format | Structure |
|---|---|
| gzip (RFC 1952) | Header starting with 1f 8b, DEFLATE data, CRC-32 and length trailer |
| deflate (zlib, RFC 1950) | Two-byte header, DEFLATE data, Adler-32 checksum |
| deflate-raw (RFC 1951) | Raw DEFLATE bitstream with no wrapper |
Common mistakes
Mistake:Expecting every file to compress well.
Fix:Gzip cannot compress already-compressed data (images, PDFs, other gzip files). It achieves 60–80% reduction on plain text and JSON, but little to none on binary files.
Mistake:Confusing gzip with deflate.
Fix:Gzip adds a 10-byte header and 8-byte footer (CRC) around the DEFLATE data. HTTP servers that advertise 'gzip' support both, but raw deflate without the header may not decompress in all clients.
Mistake:Decoding the base64 output as UTF-8.
Fix:The base64 string represents binary gzip bytes, not text. Decoding it as UTF-8 will produce garbage. Use the decompress function to recover the original text.
Frequently asked questions
How do I decompress a gzip string to text?
Switch to Decompress, paste the Base64 string, and select gzip. The bytes are inflated in your browser and the original text appears in the output panel.
What is the difference between gzip and deflate?
Both use the same DEFLATE algorithm; only the wrapping differs. gzip adds a file header, CRC-32 and a length trailer, deflate (zlib) uses a shorter header with an Adler-32 checksum, and deflate-raw omits the wrapper entirely.
Why is my compressed output larger?
Headers, checksums and the limits of entropy coding add overhead that tiny inputs cannot amortise, and data with little repetition has almost nothing to remove. The tool flags the case by showing a positive percentage instead of a saving.
Can I upload a .gz file?
No — this tool works on text and Base64 strings only. For files, unpack them locally with gunzip or your unzip utility, then paste the text here if you need a string form.
Related guides
References & standards
Related tools
Base64 Toolbox
Professional Base64 workspace for text, files and images with Base64URL, MIME, Data URI, strict validation, image preview and ready-to-use snippets.
Image Compressor
Compress JPEG, PNG, and WebP images in your browser. No uploads, completely private.
Huffman & Shannon-Fano Tree Visualizer
Build deterministic Huffman and Shannon-Fano prefix-code trees from text, with a code table, entropy, and compression metrics. Nothing leaves your browser.