Encoding

Gzip/Deflate ↔ Base64

Compress text with Gzip or Deflate, then Base64-encode the result — and back. Powered by the Compression Streams API, right in your browser.

Base64 by itself doesn't compress anything — quite the opposite, it grows the size by about 33%. To send large text compactly through a text-only channel, it's first compressed with Gzip or Deflate, and only then is the result Base64-encoded.

How to use it

Common uses

Things to keep in mind

Compression only pays off on sufficiently large, compressible text — on short strings the Gzip header overhead plus the Base64 expansion can actually make the result bigger.

Deflate skips Gzip's headers, so its output is more compact, but the format is less self-describing: the receiving side needs to know in advance that it's Deflate specifically.

Article about this tool: Gzip + Base64: compressing data for text-based transfer

Frequently asked questions

What's the difference between Gzip and Deflate here?

Gzip wraps the compressed data in a header and a trailing CRC checksum, while Deflate is the raw compression stream without that wrapper. Data compressed with one format can't be decoded by picking the other — make sure the selected format matches how the data was produced.

Why do I need to Base64-encode the compressed data?

Gzip/Deflate output is raw binary, which doesn't survive well in text contexts like URLs, JSON, or config files. Base64-encoding it turns that binary data into safe, copyable ASCII text.

Why does the tool say my browser doesn't support this?

This tool relies on the browser-native Compression Streams API (CompressionStream/DecompressionStream), which isn't available in every browser or older version — no data is sent to a server, so if it's unsupported the tool simply can't run.

Why does decompression sometimes fail with an "invalid header" error?

The most common cause is a mismatched format: data compressed as "raw" Deflate without a header, but decompressed as Gzip (which expects its own header and a CRC-32), or vice versa. Try switching the format in the tool's settings.

Does compression always reduce the final size?

No. On very short strings, the overhead of Gzip headers plus the growth from Base64 can outweigh the savings from compression — this approach only makes sense for sufficiently large, compressible text data.

Articles: Encoding

Base64: why encoding is needed and how it works

How Base64 turns binary data into ASCII text and where that is actually needed.

Base32: how it differs from Base64 and when it is more convenient

The case-insensitive Base32 alphabet and scenarios where it beats Base64.

URL Encode/Decode: percent-encoding in links

How special characters in URLs and query parameters turn into %XX sequences.

HTML Entities: how to safely output special characters on a page

Why the characters < > & need escaping and how that prevents broken markup.

JWT: token structure and what "decoding" a JWT actually means

The header, payload, and signature of a JWT, and why decoding is not the same as verifying the signature.

Unicode Escape: what \uXXXX sequences mean

Where \u0041-style sequences in JSON and JS strings come from and what they mean.

ROT13 and the Caesar cipher: simple character substitution

Why shifting by 13 letters makes ROT13 self-inverse, and why anyone still uses it today.

Punycode: how internationalized domains work in DNS

How a domain with non-Latin characters gets converted into an ASCII form with the xn-- prefix.

Morse code: how text becomes dots and dashes

The principle behind encoding letters as dots and dashes, and where Morse code is still used today.

Data URI: when to embed images directly in code

How a data: URI embeds a file’s contents directly in HTML or CSS, and when that is worth it.

XML Entities: escaping characters in XML documents

The five required XML entities without which a document breaks during parsing.