A gzip decompressor can decompress a .gz image or archive, but Gzip Compress & Decompress can restore only strictly valid UTF-8 text.

The distinction is the decompressed payload, not whether the gzip framing is valid. A .gz file may contain a JPEG, PNG, document, or tar archive. Gzip restores the original bytes; it does not convert binary data into text. The linked browser workflow is designed for UTF-8 text transported as canonical Base64.

can gzip compression decompress a gz image or archive
Can Gzip Compression Decompress a .gz Image or Archive?

Gzip's container and the file inside it

Gzip is a lossless compressed-data container, so it can carry any type of file. RFC 1952 defines a gzip stream with magic bytes 1f 8b, a compression-method value of 8 for DEFLATE, header fields, compressed blocks, and an eight-byte trailer. The trailer contains the CRC32 of the uncompressed bytes and ISIZE, which records the input size modulo 2^32.

A .gz extension identifies gzip compression, but it does not identify the original file type. For example, image.jpg.gz is a gzip-compressed JPEG, while archive.tar.gz is a tar archive compressed with gzip. Decompressing the latter produces the tar archive; a separate archive-extraction step is then needed to expose its member files.

Payload inside gzipCan gzip carry it?Correct extraction result
UTF-8 textYesRestored text
JPEG, PNG, or another imageYesThe original binary image
Single binary documentYesThe original binary file
Tar archiveYesA tar archive, followed by member extraction

Why binary payloads fail in the text workflow

The browser tool's reverse mode starts with a text field, not a binary file upload. It first applies strict RFC 4648 Base64 decoding. Missing padding, embedded whitespace, invalid alphabet characters, and nonzero pad bits are rejected. The accepted input must be the complete padded Base64 representation of an RFC 1952 gzip stream, without a data-URL prefix, filename, spaces, or line wrapping.

After decoding Base64, the tool checks the minimum gzip framing and magic bytes before passing the bytes to the browser decompressor. Corrupt or incomplete gzip data returns an error rather than partial text. The browser also verifies the compressed stream and its trailer, including the CRC32 and ISIZE values.

The decisive restriction comes next: the decompressed bytes must form valid UTF-8. An image or archive usually contains arbitrary bytes that are not valid UTF-8, so this page reports that the result is not UTF-8. It does not replace invalid bytes, display a corrupted image, or turn the result into a downloadable archive.

The implementation runs locally in the browser using the Compression Streams API. Both the input and decompressed output are limited to 5,000,000 bytes, and output is never silently truncated. A larger payload therefore needs a binary file workflow.

Extract a .gz image or archive

  1. Identify the file type. A file such as image.jpg.gz normally contains one gzip-compressed JPEG. Files named archive.tar.gz or archive.tgz contain a gzip-compressed tar archive and therefore have two layers to process.
  2. Keep the compressed file intact. Save or download the .gz file as a binary file. Do not paste its raw bytes into a UTF-8 text field or treat the file itself as a Base64 string.
  3. Use a binary gzip decompressor for a single file. Select the equivalent of a binary file “decompress” action. On a system with the gzip command, gzip -dk image.jpg.gz keeps the compressed copy and restores image.jpg.
  4. Extract a tar archive separately. An archive utility can handle both layers with tar -xf archive.tar.gz. Alternatively, gzip -dk archive.tar.gz creates archive.tar, which can then be extracted with tar -xf archive.tar.
  5. Verify the restored file. Open the image in an image viewer or inspect the archive with an archive manager. If extraction fails, confirm that the original .gz download is complete and that a binary gzip operation—not the UTF-8 text mode—was used.
  6. Review untrusted archives carefully. Extract into an empty directory, inspect the file list, and use extraction controls that prevent unwanted writes outside that directory. A gzip CRC32 can reveal accidental corruption, but it does not prove that an archive came from a trustworthy source.

These are binary-file operations. The related browser tool does not download the decompressed image, unpack tar members, or create an output file for these payloads.

Use the supported gzip Base64 text workflow

  1. Choose the correct direction. To reverse a gzip Base64 payload, select Gzip Base64 to UTF-8. To create one, select UTF-8 text to gzip Base64.
  2. Compress UTF-8 text when needed. Enter the text, select compress, and copy the complete padded Base64 result. The result contains no spaces, line wrapping, data-URL prefix, or filename.
  3. Paste only the canonical Base64 payload for reversal. The Base64 must represent a complete RFC 1952 gzip stream. Do not add quotation marks or transfer a raw .gz file into this text field.
  4. Run the decompression. The tool decodes the Base64, validates the gzip framing, decompresses the stream, checks its integrity, and then strictly decodes the result as UTF-8.
  5. Verify the restored text. Copy the output and confirm that its meaning is correct in the application that defines the content. Also confirm that the destination expects this exact container rather than raw gzip bytes, Base64 gzip, an HTTP header, or a .gz file.
  6. Switch workflows for binary content. If the expanded content is an image, archive, executable, or legacy-encoded document, use a binary gzip file tool. A UTF-8 error is the expected result of forcing a binary payload through this text-only mode.

On the compression side, the entered string is first encoded as UTF-8 bytes. Non-ASCII characters can occupy several bytes, so compressed size should not be estimated from visible character count alone.

Match the format the receiving system expects

Base64 is a text representation of gzip bytes, not the same thing as a .gz file. Confirm the required representation before copying a result into an API field, form, header, or downloadable file.

RepresentationActual contentsUse when the target asks for
A .gz fileRaw RFC 1952 gzip bytesA binary file upload or download
Base64-wrapped gzipText characters representing the gzip bytesA text field or API parameter that explicitly expects Base64
Raw gzip bytesThe uncompressed-from-Base64 RFC 1952 streamA binary API field or binary request body
Content-Encoding: gzipAn HTTP header with raw gzip bytes in the bodyAn HTTP client or server that performs content decoding

Two gzip tools may also produce different Base64 strings for the same content because header fields, compression levels, and DEFLATE choices can differ. Validate the gzip framing and restored content rather than expecting one exact compressed string. By contrast, two Base64 strings that decode to the same bytes are equivalent.

Diagnose failures at the correct layer

  • Base64 errors: The input may contain missing padding, whitespace, invalid characters, or invalid pad bits. Regenerate the canonical padded Base64 without a prefix or filename.
  • Gzip errors: A bad magic value, unsupported method, damaged compressed block, or incomplete trailer points to invalid gzip data rather than a text-encoding problem.
  • Not-UTF-8 errors: The gzip stream may be completely valid while its expanded bytes represent an image, archive, executable, or non-UTF-8 document. Use a binary file decompressor for that output.
  • Size-limit errors: The input or expanded output exceeds the tool's 5,000,000-byte boundary. The page does not return a partial or truncated result.
  • Content mismatches: A syntactically valid stream can still expand to unexpected text. Confirm the source, encoding, and semantics in the application that consumes the result.

Gzip compression is not encryption, secrecy, authentication, or sanitization. Anyone with the compressed data can decompress it, and CRC32 is intended to detect accidental corruption rather than attacks by a modified payload. Use the browser text workflow only when the original content is UTF-8 and the receiving system explicitly expects the same Base64-wrapped gzip representation.