Oh MyUtils

GZIP Compress & Decompress - Base64 GZIP Encoder Online

Compress and decompress text or files using GZIP with Base64 output. View compression statistics, download .gz files — 100% client-side, no data sent to server.

Input
Output
100% client-side — your data never leaves your browser

Frequently Asked Questions

What is GZIP compression?

GZIP is a file format and compression algorithm based on the DEFLATE algorithm (a combination of LZ77 and Huffman coding). It is the most widely used compression format on the web — virtually all HTTP servers and browsers support it via the Content-Encoding: gzip header. A GZIP file consists of a 10-byte header, the DEFLATE-compressed body, and an 8-byte footer containing a CRC32 checksum and the original uncompressed size.

How do I use this tool?

Select the Compress or Decompress tab. To compress, enter text in the input area or drag-and-drop a file, and the compressed output appears as a Base64-encoded string you can copy or download as a .gz file. To decompress, paste a Base64-encoded GZIP string or drop a .gz file, and the original text will appear. View compression statistics to see how effective the compression was.

Is my data safe? Does it get sent to a server?

Your data is 100% safe and never leaves your browser. All compression and decompression is performed entirely client-side using the browser's native CompressionStream and DecompressionStream APIs. No data is transmitted to any server, making this tool safe for compressing sensitive data such as API keys, authentication tokens, and proprietary content.

What is the difference between GZIP and Deflate?

GZIP and Deflate use the same underlying compression algorithm (DEFLATE, RFC 1951). The difference is the wrapper: GZIP adds a 10-byte header and 8-byte footer around the Deflate-compressed data. For very small inputs (under ~50 bytes), the 18-byte GZIP overhead can make the compressed output larger than the original. On the web, Content-Encoding: gzip is the standard.

Why is my compressed output larger than the input?

GZIP adds an 18-byte overhead (10-byte header + 8-byte footer) plus Deflate compression metadata. For very short strings (typically under 50-100 bytes), the overhead exceeds the compression savings. This is expected behavior. GZIP is most effective on larger text with repetitive patterns such as HTML, JSON, XML, or log files.

What is Base64-encoded GZIP and when is it used?

Base64-encoded GZIP is the result of compressing data with GZIP and then encoding the binary bytes as a Base64 ASCII string. This is commonly used for storing compressed data in JSON/XML fields, embedding compressed payloads in URLs, transmitting compressed data through text-only protocols, and compressing localStorage values in web applications.

Which browsers support this tool?

This tool uses the CompressionStream and DecompressionStream Web APIs, supported in Chrome 80+, Edge 80+, Safari 16.4+, and Firefox 113+. All major modern browsers support these APIs. If your browser does not support them, the tool will display an error message.

Code Examples

// Compress text to Base64-encoded GZIP
async function compressToBase64(text) {
  const stream = new Blob([new TextEncoder().encode(text)])
    .stream()
    .pipeThrough(new CompressionStream('gzip'));
  const buf = await new Response(stream).arrayBuffer();
  let binary = '';
  new Uint8Array(buf).forEach(b => binary += String.fromCharCode(b));
  return btoa(binary);
}

// Decompress Base64-encoded GZIP to text
async function decompressFromBase64(base64) {
  const binary = atob(base64);
  const bytes = Uint8Array.from(binary, c => c.charCodeAt(0));
  const stream = new Blob([bytes])
    .stream()
    .pipeThrough(new DecompressionStream('gzip'));
  return await new Response(stream).text();
}

// Usage
const compressed = await compressToBase64('Hello, World!');
console.log(compressed);
const decompressed = await decompressFromBase64(compressed);
console.log(decompressed); // "Hello, World!"

Related Tools