Skip to content
UniKit

Deflate & Gzip compressor

Compress and decompress data in the browser with raw Deflate (RFC 1951), zlib (RFC 1950) and gzip (RFC 1952) — output stays compatible with zlib and gzip tooling.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

All three formats are interoperable: Deflate matches zlib.deflateRaw / inflateRaw, Zlib matches zlib.deflate / inflate and Gzip matches zlib.gzip / gunzip. The gzip mtime is fixed at 0 so output is reproducible.

Result

What this tool does

  • Inspect compressed data by hand: paste the hex or Base64 of gzip, zlib or raw Deflate output and decompress it to see what is inside.
  • Prepare test fixtures: compress text into gzip Base64 and drop it into a response header or a mock endpoint.
  • Debug "decompression failed": try the three formats (raw Deflate, zlib, gzip) in turn to find out which one the payload actually is.
  • Estimate the payoff of compression: input and output sizes plus the ratio are shown, so you can tell whether a layer of compression is worth it.

Example

Input

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. (format Gzip, output encoding Base64)

Output

H4sIAAAAAAAAAwvJSFUoLM1MzlZIKsovz1NIy69QyCrNLShWyC9LLVIoAUrnJFZVKqTkp+sp0EwxAAYoahGGAAAA

The raw text is 134 bytes and the compressed output 66 bytes, a ratio of about 50.7%. The gzip mtime is fixed at 0, so the same input always produces byte-identical output.

Frequently asked questions

How do the three formats differ?

Deflate (RFC 1951) is the bare stream with no header or checksum; zlib (RFC 1950) wraps it with a 2-byte header and an Adler-32 checksum; gzip (RFC 1952) adds a 10-byte header and CRC32. Picking the wrong format fails immediately with "cannot be decompressed with the selected format".

Is it compatible with the command-line gzip and zlib tools?

Yes. Deflate matches zlib.deflateRaw / inflateRaw, Zlib matches zlib.deflate / inflate and Gzip matches zlib.gzip / gunzip. The fflate implementation in the browser is byte-compatible with all of them in both directions.

What if the decompressed result is not text?

It means the original payload is binary (an image, protobuf, archive). Switch the output encoding to Hex or Base64 to inspect the bytes; a strict UTF-8 decode failure is reported as "the result is not valid UTF-8 text".

Why did the data get bigger after compressing?

That is normal. The gzip header alone is 10 bytes and there are Deflate block headers on top, so short strings often grow and the ratio is shown as negative. The benefit only appears with larger, more repetitive input.

Is my data uploaded anywhere?

No. Compression, decompression and byte encoding all run in the browser, the page makes no network requests, and it works offline.

Keywords:deflategzipzlib压缩解压compressdecompressinflate压缩率rfc 1951rfc 1952

Related tools