Skip to content
UniKit

JS text gzip compression

Real compression with the bundled pure-JS fflate dependency: gzip (RFC 1952), deflate (RFC 1951) and zlib (RFC 1950) with level 0–9, output as Base64 or hex, plus input/output byte counts and the saved percentage. Switch to decompress mode (options.mode = "decompress") to restore the original text. The gzip mtime is fixed at 0, so the same input always produces the same bytes. Boundary: the output is a binary byte stream and must be carried as Base64 or hex.

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

Input

Result

The result can be copied directly.

Paste content to compress (decompress mode expects Base64 or hex)

Characters: 0 · Input bytes: 0 · Output bytes: 0 · Saved (%): 0

What this tool does

  • Estimate how many bytes a text or JSON payload saves under gzip.
  • Prepare a pasteable Base64 compressed body for API debugging.
  • Paste the result back to verify decompression.

Example

Input

hello hello hello hello hello hello hello

Output

H4sIAAAAAAAAA8tIzcnJVyCCBAA0TwcyKQAAAA==

Compression and decompression run locally with fflate (real gzip/deflate/zlib byte streams), not whitespace stripping. The gzip mtime is pinned to 0 so results are reproducible.

Frequently asked questions

Is this really gzip?

Yes. It uses fflate gzipSync / deflateSync / zlibSync to produce real byte streams (RFC 1952 / 1951 / 1950) that gunzip or zlib can decode. It is not whitespace-stripping pseudo compression.

Why is the ratio sometimes negative?

For short text the gzip header (about 18 bytes) is larger than the payload, so a negative ratio means it grew. Longer, more repetitive text benefits much more.

How do I use the output?

Base64 or hex are pasteable text representations. To decompress, paste the same string back, pick the same algorithm and encoding and switch to decompress mode.

Can it compress binary files?

The page input is text, so compression is over UTF-8 text here. For binary files use a zip / file compression tool (also built on fflate).

Keywords:jsgzipdeflatezlib

Related tools