Gzip Compress and Decompress Text or Files – Free

Gzip compress text or a file, or decompress gzip data from a .gz file or a Base64 string. The tool uses your browser's native compression streams, so nothing is uploaded.

How to use the Gzip compress / decompress tool

  1. In Operation, choose Encode to compress or Decode to decompress.
  2. To work on a file, pick one of up to 20 MiB under File (optional). A chosen file takes priority over the text box.
  3. Otherwise fill in Text to compress or Base64 gzip data: plain text for Encode, Base64 of a gzip stream for Decode.
  4. Select Convert. Select Example to compress the sample text Hello, world! and see the output format.
  5. Read the Result box: Base64 after compressing, or text or a hex dump after decompressing.
  6. Select Download to save the .gz or decompressed file, or Copy to copy the text.

How gzip compression works

Gzip is a container, defined in RFC 1952, around the DEFLATE algorithm from RFC 1951. DEFLATE combines two ideas. LZ77 replaces a repeated run of bytes with a short reference to an earlier copy inside a 32 KiB window, and Huffman coding then gives frequent symbols shorter bit patterns.

Around the compressed body gzip adds a 10-byte header starting with 1F 8B 08 and an 8-byte trailer with a CRC-32 and the original length. Those 18 bytes are why very short inputs get bigger.

Gzip compress example with real numbers

The 13 bytes of the sample sentence compress to 33 bytes. Nothing in it repeats, so the DEFLATE body comes to 15 bytes and the header and trailer add 18. A thousand bytes made of abc and a space repeated 250 times compress to 32 bytes.

The Base64 below was produced in Chrome. Another browser's compressor may make different choices and give a different string for the same input. Any gzip decoder still restores the identical text.

Encode:  Hello, world!
→  H4sIAAAAAAAAA/NIzcnJ11Eozy/KSVEEAObG5usNAAAA

Decode:  H4sIAAAAAAAAA/NIzcnJBwCCidH3BQAAAA==
→  Hello

Input, output and limits

What you get depends on the operation and on whether a file is selected. The compression level is chosen by the browser. Decompressed data that is valid UTF-8 is shown as text. Other data is shown as a byte count with the first 256 bytes in hex.

  • Encode with text: the text is converted to UTF-8 and compressed. The download is named text.txt.gz.
  • Encode with a file: the file's bytes are compressed, and the download keeps the file name with .gz added.
  • Decode with Base64: standard or URL-safe Base64 is accepted, with or without padding, and a data URL prefix is stripped.
  • Decode with a file: the download drops a trailing .gz from the name. Decoded Base64 input is saved as decompressed.bin.
  • Files are limited to 20 MiB, and any result, compressed or decompressed, to 40 MiB.

Why decompression fails

Decode expects one complete gzip stream. For the three causes in the middle, the message text comes from the browser.

  • The text is not Base64. Plain text in Decode mode gives Enter valid Base64 or choose a file.
  • The data is Base64 but not gzip. Zlib and raw DEFLATE streams lack the gzip header.
  • The stream is truncated or corrupted, so the CRC-32 or length comparison at the end does not pass.
  • Extra bytes follow the gzip trailer, as in files built by concatenating several gzip streams.
  • The decompressed size passes 40 MiB, which gives The result exceeds the 40 MiB limit.

Frequently asked questions

How do I open a .gz file without installing software?

Choose Decode, pick the file under File (optional) and select Convert. Text content appears in the Result box, and Download saves the decompressed file under its name without the .gz ending.

Why is my gzip output larger than the input?

Gzip adds 18 bytes of header and trailer, and short or random data has no repetition to exploit, so small inputs often grow. Compression pays off on larger, repetitive content such as JSON, HTML, CSS and logs.

Why is the compressed result shown as Base64?

Gzip output is binary and cannot be shown or copied as plain text without damage. Base64 gives a safe text form for JSON, environment variables or test fixtures. Use Download when you need the actual .gz file.

Are my files uploaded during compression?

No. The browser's CompressionStream and DecompressionStream do the work on your device, and the download link points to data held in the page's memory.

Related tools