FormatterHQ

Gzip Compress

Compress text with gzip at the level you choose and get the result as Base64 or hex text, or download it as a .gz file.

Input TEXT
Output TEXT
Ready.

How to use the Gzip Compress

  1. Paste the text you want to compress into the input editor, upload a file, or click Sample to load an example.
  2. Set the Level (1 = fastest, 9 = smallest) and choose Base64 or Hex Output.
  3. Click Compress in the options panel. With Auto update ticked, the result refreshes as you type.
  4. Copy the result from the output panel or download it as a file.

Gzip compress text in your browser

Gzip (RFC 1952) is the compression format behind .gz files, HTTP Content-Encoding: gzip and countless log archives. This tool will gzip compress any text you paste and show the compressed bytes as Base64 or hex, so you can embed them in JSON, an environment variable, a test fixture or an API request — or download the binary .gz file directly.

Example

Input (38 bytes):

Hello world! Hello world! Hello world!

Gzip, Base64 encoded:

H4sIAAAAAAAAA/NIzcnJVyjPL8pJUVTwwMUBAFSjmmImAAAA

Every gzip stream starts with the bytes 1F 8B, which is why gzip data in Base64 almost always begins with H4sI.

What is inside a gzip file

  • A 10-byte header: magic number, compression method (DEFLATE), flags and a timestamp.
  • The DEFLATE-compressed data (RFC 1951), which combines LZ77 back-references with Huffman coding.
  • An 8-byte trailer with a CRC-32 checksum and the original length, used to detect corruption.

Those 18 bytes of overhead mean very short inputs get larger when compressed — “Hi” grows from 2 to 22 bytes. Gzip pays off on longer or repetitive text such as JSON, logs, HTML and CSV, which commonly shrink by 60–90%.

Choosing a level

LevelTrade-off
1–3Fastest, slightly larger output. Good for real-time streams.
6The default in gzip and zlib — a balanced choice.
9Smallest output, slowest. Best for files compressed once and read many times.

For small text the difference between levels is often a few bytes; the status bar shows the exact before and after sizes.

Why outputs from different tools differ

The gzip header contains a modification time and an operating-system byte, and compressors may choose slightly different matches at the same level. Two tools can therefore produce different bytes for the same input — both valid, and both decompressing to identical text. Compare decompressed content, not compressed bytes. On the command line, gzip -c file | base64 produces comparable output; in code, use gzip.compress() in Python or zlib.gzipSync() in Node.js.

Gzip vs. zlib vs. Base64

Gzip and zlib use the same DEFLATE algorithm with different wrappers: gzip is for files and HTTP, zlib for data embedded inside other formats. Base64 is not compression at all — it makes data about 33% larger so it can travel as text. Compressing first and then Base64-encoding usually still wins for text larger than a few hundred bytes.

Decompress with Gzip Decompress. Compression runs entirely in your browser.

Frequently asked questions

Why is my compressed output bigger than the input?
Gzip adds 18 bytes of header and trailer, and very short or random text cannot be compressed much. Compression is worthwhile for longer, repetitive content.
Can I download a real .gz file?
Yes. Use the Download button on the output panel to save the binary gzip data as data.gz. It opens with gunzip, 7-Zip or any archive tool.
Which compression level should I use?
Level 6 is the standard default. Use 9 for the smallest result when speed does not matter, and 1 when speed is more important than size.
Is gzip the same as ZIP?
No. Both use DEFLATE, but ZIP is an archive format that can hold many files with a directory, while gzip compresses a single stream.

Last updated September 26, 2026

Related tools