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/NIzcnJVyjPL8pJUVTwwMUBAFSjmmImAAAAEvery 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
| Level | Trade-off |
|---|---|
| 1–3 | Fastest, slightly larger output. Good for real-time streams. |
| 6 | The default in gzip and zlib — a balanced choice. |
| 9 | Smallest 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.