Skip to content
DevToolKit

GZIP Compress & Decompress

Compress and decompress GZIP files entirely in your browser using the native Compression Streams API. Extracts original filenames, shows compression ratios, and handles files of any size.

Drop any file to compress

Any file type accepted — compressed using GZIP

Native Browser Compression

This tool uses the CompressionStream API built into your browser. No files are uploaded — everything is processed locally using the same zlib engine that powers web servers and command-line tools. Drop a .gz file and the tool auto-switches to decompress mode.

Processed locally
Was this tool helpful?

How to Use

Compress any file into GZIP format or decompress existing .gz files, all within your browser. No uploads, no installations, no file size limits.

Compressing a File

  1. Select Compress mode using the segmented control at the top. This is the default mode when the tool loads.
  2. Drop or select your file. Any file type is accepted — text files, JSON, CSV, log files, executables, or any other format. There is no file size restriction.
  3. Wait for processing. A progress bar shows the compression progress in real time. The browser's native CompressionStream API handles the work in chunks, so even large files can be compressed without exhausting memory.
  4. Review results. Once complete, the tool shows the original size, compressed size, compression ratio as a percentage, and total processing time.
  5. Download the compressed file. Click the download button to save the .gz file. The output filename is your original filename with .gz appended.

Decompressing a File

  1. Select Decompress mode using the segmented control — or simply drop a .gz file while in Compress mode. The tool auto-detects GZIP format by checking the first two bytes for the magic number 0x1f 0x8b and switches to Decompress automatically.
  2. Drop or select the GZIP file. While .gz is the standard extension, the tool validates by magic bytes rather than file extension.
  3. Review results. The tool displays the compressed size, decompressed size, compression ratio, processing time, and — when available — the original filename extracted from the GZIP header (RFC 1952 FNAME field).
  4. Download the decompressed file. The output filename defaults to the original filename from the GZIP header. If that is unavailable, the tool strips the .gz extension from the input filename.

About This Tool

The Compression Streams API

This tool relies on the Compression Streams API, a web standard implemented natively in Chrome 80+, Firefox 113+, Safari 16.4+, and Edge 80+. The API exposes two transform stream classes: CompressionStream and DecompressionStream, which pipe readable streams through the browser's built-in zlib implementation. Because zlib is compiled into the browser engine itself, there is no JavaScript or WebAssembly overhead — compression runs at near-native speed.

GZIP Format: RFC 1952

GZIP is a file format defined in RFC 1952 (1996). It wraps a single DEFLATE-compressed data stream with a 10-byte mandatory header and an 8-byte trailer. The header contains a magic number (0x1f 0x8b), the compression method (always DEFLATE, value 8), a flags byte, a 4-byte Unix timestamp, extra flags, and an operating system identifier. The trailer contains a CRC32 checksum and the original uncompressed size modulo 232.

The flags byte controls optional header extensions. The most useful is FNAME (bit 3), which stores the original filename as a null-terminated ISO 8859-1 string. This tool reads the FNAME field when decompressing and uses it as the default download filename, so users get back the exact original name.

The DEFLATE Algorithm

DEFLATE (RFC 1951) is the actual compression algorithm inside GZIP. It combines LZ77 sliding-window matching with Huffman coding. LZ77 replaces repeated byte sequences with back-references (distance, length pairs), while Huffman coding assigns shorter bit patterns to more frequent symbols. The result is lossless compression that typically achieves 60-80% reduction on text and structured data.

Streaming Architecture

This tool processes files as streams rather than loading them entirely into memory. The File.stream() method provides a ReadableStream that reads the file in chunks. This stream is piped through CompressionStream or DecompressionStream, and the output chunks are collected into a final Blob. This means a 500 MB file does not require 500 MB of free memory — the browser processes it incrementally.

Why Use This Tool

When to Use GZIP Compression

GZIP is one of the most widely supported compression formats in computing. Here are the most common use cases:

  • Reducing file transfer sizes — Compress log files, CSV exports, JSON datasets, or SQL dumps before sending them over email or uploading to cloud storage. Text-heavy files typically shrink by 70-90%.
  • HTTP content encoding — Web servers use GZIP to compress HTML, CSS, and JavaScript before sending them to browsers. The Content-Encoding: gzip header is supported by every major browser and CDN. Understanding GZIP helps developers debug network payloads.
  • Creating .tar.gz archives — In Unix and Linux environments, .tar.gz (or .tgz) is the standard archive format. The tar file bundles multiple files into one stream, and GZIP compresses that stream. This tool handles the GZIP layer — pair it with a tar utility for full archive support.
  • API payload compression — REST and GraphQL APIs often accept GZIP-compressed request bodies via the Content-Encoding: gzip request header. Compressing large JSON payloads before sending can reduce bandwidth usage by 80% or more.
  • Log file compression — Production servers generate gigabytes of log files daily. GZIP compresses log files by 85-95% because log entries are highly repetitive. Rotated log files are commonly stored as .log.gz.
  • Database backups — PostgreSQL, MySQL, and MongoDB dump utilities support piping output through GZIP. A 10 GB database dump might compress to 1-2 GB, making backups faster to store and transfer.

Privacy

Your files never leave your browser. The Compression Streams API runs entirely within the browser engine — no data is sent to any server, no temporary files are created on remote infrastructure, and no third-party code is involved. This makes the tool safe for compressing sensitive documents, configuration files with credentials, or proprietary data.

FAQ

How does browser-native GZIP compression work?
Modern browsers include the Compression Streams API, which provides native CompressionStream and DecompressionStream classes. These use the browser's built-in zlib implementation — the same library used by Node.js, Python, and most server-side platforms. Data is piped through the stream in chunks, so files of any size can be processed without loading the entire file into memory at once.
What is the difference between GZIP and ZIP?
GZIP compresses a single file using the DEFLATE algorithm and wraps it in a GZIP container with metadata such as the original filename, timestamp, and CRC32 checksum. ZIP is an archive format that can contain multiple files and directories, each individually compressed. GZIP is the standard for HTTP content encoding and Unix/Linux file compression (.tar.gz). ZIP is the standard for multi-file archives on Windows and cross-platform distribution.
Can this tool extract the original filename from a .gz file?
Yes. The GZIP format (RFC 1952) includes an optional FNAME field that stores the original filename before compression. When this field is present, the tool displays it and uses it as the default download filename during decompression. If the field is not set (some compressors omit it), the tool falls back to stripping the .gz extension from the input filename.
What compression ratio should I expect?
Compression ratio depends entirely on the input data. Text files typically achieve 60-80% reduction. JSON and XML files often compress by 70-90%. Already-compressed files (JPEG, PNG, MP4, ZIP) will see little to no reduction and may even grow slightly due to the GZIP header overhead. Binary executables typically compress by 30-50%.