GZip Compressor

Compress and decompress text with gzip, deflate, or deflate-raw

Direction:
Format:

Text Input

Output

Output will appear here

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

    Input
    text: The quick brown fox jumps over the lazy dog.
    Output
    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

    Input
    H4sIAAAAAAAAA3PP0sivyCxIVAguLilK5XBkBQAQ/wb/EAAAAA==
    Output
    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

    Gzip is a widely-used lossless compression format defined in RFC 1952. It wraps the DEFLATE algorithm (a combination of LZ77 and Huffman coding) in a container with a header, optional metadata, and a CRC-32 checksum. The browser's native CompressionStream and DecompressionStream APIs expose gzip compression without any external library.

    This tool compresses text to gzip, deflate, or deflate-raw, and decompresses back to text — all in the browser with no server calls. The output is base64-encoded so it can be copied as a string, and the compression ratio and compressed size are shown alongside the result.

    How to use

    1. Choose compress or decompress

      Pick Compress to gzip/deflate text, or Decompress to decode a compressed byte stream back to text.

    2. Select a format

      Choose gzip (with header and checksum), deflate (raw), or deflate-raw. Gzip is the most widely compatible; deflate-raw omits the header.

    3. Read the result

      The compressed or decompressed output is shown, along with the size ratio (e.g. '72% smaller') and byte count. Copy the base64 output or download it as a .gz file.

    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.

    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

    References & standards