How to use the Gzip Compress
Compress text with gzip in three steps:
1
Paste text and select level
Paste any text or click 'Load Sample'. Choose compression level 1 (fast, less compression) through 9 (slow, maximum compression). Level 6 is the gzip default used by nginx and most web servers.
2
Click Gzip Compress
fflate compresses the text instantly using RFC 1952 gzip format with a proper gzip header. Stats panel shows original bytes, compressed bytes, savings %, and a visual bar chart.
3
Copy or download the output
Select Base64 or Hex output format for text transport. Click Copy to copy encoded output. Download the .gz binary for server deployment or file storage.
When to use this tool
Use the Gzip Compressor for universal compression compatible with every web server and browser:
- →Compressing HTML, CSS, and JavaScript for web servers using Content-Encoding: gzip — supported by every browser and server since the late 1990s
- →Generating gzip-compressed test fixtures for API integration tests that verify Content-Encoding handling in your HTTP client
- →Pre-compressing static files for nginx (gzip_static on) or Apache (mod_deflate) to eliminate runtime CPU overhead
- →Compressing configuration and data files before embedding them as Base64 strings in environment variables or deployment manifests
- →Creating reproducible .gz files for file format testing, binary protocol debugging, or compression benchmarking
- →Compressing large JSON or CSV payloads before uploading them to cloud storage to reduce transfer costs and storage size
Frequently asked questions
Q:What is the difference between gzip and DEFLATE, and what format does this tool produce?
DEFLATE is the compression algorithm (LZ77 + Huffman coding). Gzip is a file format that wraps DEFLATE compressed data with a 10-byte header (magic bytes 1F 8B, compression method, flags, timestamp, OS identifier) and a CRC-32 checksum trailer. Zlib is another wrapper format that adds a 2-byte header and Adler-32 checksum. This tool produces proper gzip format (RFC 1952) output — it starts with magic bytes 0x1F 0x8B, which means it can be decompressed by gunzip, gzip -d, Python's gzip module, and any gzip-aware library. The magic bytes H4sI in Base64 output always indicate a valid gzip stream.
Q:Which compression level should I choose?
Level 6 is the standard default used by nginx, Apache mod_deflate, and most gzip implementations — it gives good compression with fast speed. Level 1 is appropriate for real-time dynamic responses where latency matters more than bytes (API responses generated per-request). Level 9 gives the best compression at significantly higher CPU cost — use it for static assets that are compressed once at build time and served thousands of times, making the one-time compression cost worthwhile. For most development and testing purposes, level 6 is the right choice. Levels 4–7 are all within about 5% of level 9's compression size.
Q:Why does gzip sometimes make small files larger?
Gzip adds a fixed 18-byte overhead (10-byte header + 8-byte trailer) before any compressed data. For very short inputs (under ~50 bytes), the DEFLATE compressed data plus this overhead can exceed the original size. Additionally, content with no repeating patterns (like random data, encrypted data, or already-compressed binary formats) cannot be compressed — DEFLATE finds no LZ77 back-references to exploit, so the output consists of uncompressed literal blocks plus overhead. The tool shows 'larger' in orange when this occurs. Below about 150 bytes or for high-entropy input, use no compression, or use a format with lower overhead like raw DEFLATE.
Q:Can I decompress the .gz file produced by this tool with standard tools?
Yes — the .gz output is a standard RFC 1952 gzip file compatible with all gzip implementations: gunzip filename.gz, gzip -d filename.gz, Python's gzip module, Java's GZIPInputStream, Node.js's zlib.gunzip, the browser's DecompressionStream API, and the companion Gzip Decompress tool on this site. The Base64 output can also be decompressed by the Gzip Decompress tool — paste the Base64 string and it recovers the original text. The magic byte validation (0x1F 0x8B) in the decompressor ensures you're working with a valid gzip stream.
Q:What is fflate and is it as accurate as native gzip?
fflate (fast FLATE) is a pure JavaScript implementation of DEFLATE, gzip, and zlib compression that produces byte-for-byte compatible output with native gzip. It uses the same RFC 1952 gzip standard and the same DEFLATE algorithm — data compressed with fflate can be decompressed by native gunzip and vice versa. fflate is used in production by many npm packages and achieves near-native performance through careful JavaScript optimization. Compression ratios are identical to native gzip at the same level — the output is not an approximation or a different format.
Q:How does gzip handle multi-byte UTF-8 characters like emoji?
Gzip compresses bytes, not characters. This tool first encodes your text to UTF-8 bytes (using TextEncoder), then gzip-compresses the byte stream. Multi-byte UTF-8 characters like emoji (4 bytes each) and accented letters (2–3 bytes each) are handled correctly. When decompressed, the gzip output is the original UTF-8 byte sequence, and TextDecoder reconstructs the exact original text. The byte count displayed in the status bar shows UTF-8 bytes, not character count — 'Hello 😀' has 7 characters but 10 UTF-8 bytes. This is the correct behaviour and matches what web servers gzip-encode in practice.