To gzip compress a string, convert it to UTF-8 bytes, compress those bytes with gzip, and Base64-wrap the binary result when it must travel through a text field. The Gzip Compress & Decompress tool performs that workflow locally in your browser and produces canonical padded Base64 around an RFC 1952 gzip stream. Its reverse mode accepts that exact container and restores strictly valid UTF-8 text.
Gzip and Base64 serve different purposes. Gzip is the compression layer, while Base64 is a transport encoding that represents binary bytes with text characters. A receiver may need raw gzip bytes, Base64-wrapped gzip, an HTTP Content-Encoding: gzip response, or a gzip file. Confirming that distinction before compressing prevents a valid payload from being rejected by the destination.

What a gzip-compressed string contains
The conversion follows one clear path: string → UTF-8 bytes → RFC 1952 gzip stream → canonical Base64 text. The original string is encoded as UTF-8 before compression. That matters because the number of visible characters is not necessarily the number of bytes processed: non-ASCII characters can require several UTF-8 bytes.
The browser uses the Compression Streams API to create the gzip byte stream. According to the RFC 1952 gzip specification, the stream begins with the magic bytes 1f 8b, followed by a compression-method value of 8 for DEFLATE. It also contains header fields, compressed blocks, and an eight-byte little-endian trailer.
That trailer holds a CRC32 value for the uncompressed bytes and an ISIZE value representing the input size modulo 2^32. These fields help the decoder identify accidental damage and confirm basic stream properties. They do not make gzip an authenticated format.
After compression, the binary stream is encoded as padded Base64 without spaces, line wraps, a data URL prefix, or a filename. The resulting string is therefore Base64 text containing gzip data—not ordinary Base64 of the original text. A receiver must decode the Base64 first and then decompress the resulting bytes.
Compress a string into pasteable gzip Base64
Use this workflow when the destination explicitly expects a Base64 field containing gzip-compressed UTF-8 data.
- Open the tool and choose UTF-8 text to gzip Base64. Paste or type the source string into the input area, preserving spaces, line breaks, punctuation, and Unicode characters exactly as they should appear after restoration.
- Check the input against the 5,000,000-byte limit. The limit applies to the UTF-8 bytes, not the number of visible characters, so a shorter string with multibyte characters can still approach it.
- Select compress. The browser converts the string to UTF-8 bytes and creates an RFC 1952 gzip stream through the browser’s native compression implementation.
- Copy the complete padded Base64 result with the copy action. Do not remove the = padding or add whitespace, a data: prefix, or a filename unless the receiving system explicitly requires that additional formatting.
- Confirm that the destination expects Base64-wrapped gzip. Do not submit this value to a field that requires raw gzip bytes or treat it as a manually configured HTTP Content-Encoding value.
- For a round-trip check, paste the copied value into Gzip Base64 to UTF-8, run decompress, and compare the restored text with the original source.
The result can be copied as one continuous Base64 string. If the receiving application requires a different arrangement, such as a raw binary request body or a downloadable file, use a workflow that creates that exact container instead of altering the Base64 by hand.
Restore the original text from gzip Base64
Decoding reverses the same layers in the opposite order. Base64 must become gzip bytes before the gzip stream can become text.
- Choose Gzip Base64 to UTF-8 in the tool.
- Paste only the canonical Base64 payload. The strict decoder accepts padded Base64 representing an RFC 1952 gzip stream; missing padding, embedded whitespace, invalid alphabet characters, and nonzero pad bits are rejected.
- Select decompress. The tool checks the minimum gzip framing and magic bytes before passing the data to the browser decompressor. The browser then verifies the compressed stream and trailer.
- Copy the restored text after successful decompression. Corrupt or incomplete gzip data returns an error rather than a partial string.
- Compare the result with the expected content and its application meaning. A successful byte-level restoration confirms that the container worked, but the receiving application still needs to recognize the restored value as the correct record, field, or message.
A gzip stream can technically contain any kind of binary data, but this page deliberately returns text only. If the decompressed bytes are not valid UTF-8, the strict decoder reports that fact instead of replacing invalid sequences with substitute characters.
How the tool validates the payload
Validation happens at each layer rather than relying on a successful-looking output string. During compression, the browser creates the gzip framing through CompressionStream("gzip"). The product’s fixtures then verify the RFC magic and method bytes, perform real decompression, and independently inspect the trailer’s CRC32 and ISIZE against known check values.
- Base64 validation: Strict RFC 4648 decoding rejects malformed text before any gzip processing begins.
- Gzip validation: The minimum framing and magic bytes are checked before decompression, and the browser verifies the compressed stream and trailer.
- UTF-8 validation: Decompressed bytes must form valid UTF-8. Invalid or legacy-encoded text is not silently rewritten.
- Failure behavior: Corrupt, incomplete, or wrongly encoded input returns an error rather than partial text, and output is never silently truncated.
CRC32 is useful for detecting accidental corruption, but it is not a cryptographic integrity guarantee against an attacker. It can tell a decoder that bytes do not match the recorded checksum; it does not prove that a deliberately modified file is authentic.
Do not expect two gzip tools to produce the exact same Base64 spelling for the same source. Header fields, DEFLATE choices, and compression levels can differ while the streams restore identical content. Validate the framing and restored bytes instead of comparing one compressed string to a hard-coded result from another encoder.
Match the result to the receiver’s required container
The safest way to use a gzip-compressed string is to follow the receiving system’s format specification. These delivery forms may contain related gzip data, but they are not interchangeable.
| Format requested | Data carried | How this page fits |
|---|---|---|
| Raw gzip body | An RFC 1952 binary gzip stream | This page does not emit raw binary directly. Use a binary gzip workflow when the endpoint expects raw gzip bytes. |
| Base64-wrapped gzip | Base64 characters representing the gzip stream | This is the direct output of the tool when the receiver decodes Base64 and then decompresses it. |
| HTTP Content-Encoding: gzip | A gzip-encoded HTTP body interpreted through the HTTP encoding rules | Configure the header in the HTTP client or server. Do not manually insert Base64 into the header or body unless the application contract separately requests that wrapper. |
| Gzip file | A gzip stream stored as a file | Use a binary file workflow for arbitrary files. The text page returns a Base64 value and does not create a downloadable gzip file. |
If the documentation says only “gzip,” do not assume Base64 is wanted. Look for wording such as “Base64-encoded gzip,” “decode Base64 before inflating,” or “raw gzip request body.” When the required order remains unclear, test the workflow with a non-sensitive sample before sending important data.
Size limits and unsupported payloads
Both the input and the decompressed output are limited to 5,000,000 bytes. The cap protects against accidental large pastes and against decompression expansion that could freeze the browser tab. The tool does not solve these conditions by quietly cutting off data; an oversized result fails rather than appearing complete.
The limits are byte-based, so calculate against UTF-8 size when the text contains non-ASCII characters. The interface also cancels stale asynchronous results when the mode or input changes, preventing an older compression job from replacing a newer value.
Images, archives, executables, and documents encoded with a legacy character set are outside this page’s text workflow. Even when such content sits inside a valid gzip stream, the final bytes must still be valid UTF-8. Use a binary file decompressor for those payloads. Choosing a text-oriented path for arbitrary binary data can turn a supported gzip container into an unsupported output type.
Compression is not protection for secrets
Gzip compression is not encryption, secrecy, authentication, or sanitization. The format is widely available, and anyone with the compressed bytes can decompress them. Compressed text can also reveal recognizable patterns to tools that inspect the gzip stream.
Local browser processing means the compression operation occurs on the device rather than requiring the source text to be uploaded to a remote compression service. That processing location does not change what gzip itself guarantees. Do not treat the output as protection for credentials, personal information, or other sensitive material; use an appropriate security mechanism when secrecy or authenticated integrity is required.
Check the handoff before sending
- Confirm that the receiver wants Base64-wrapped gzip rather than raw gzip bytes, an HTTP encoding header, or a file.
- Keep the Base64 padding intact and remove any accidental whitespace before pasting.
- Confirm that the source stays within the 5,000,000-byte input limit.
- Use a round-trip decompression check before sending a critical payload.
- Switch to a binary gzip workflow whenever the decompressed content is not valid UTF-8.
- Keep secrets out of payloads that rely on gzip alone for protection.
For the “gzip compress string” task specifically, the complete browser workflow is to produce UTF-8 bytes, create an RFC 1952 gzip stream, copy its canonical padded Base64 representation, and decode that wrapper only when the destination explicitly expects it.
If you're weighing options, Base32 Decode on Windows: A Complete Local Workflow covers this in detail.
If you're weighing options, Base64 Decode in PowerShell: UTF-8 Strings and Files covers this in detail.