GZIP archive file (.gz)
.gz file signature | application/gzip
GZIPcompressed file[61]
Magic Bytes
Offset 0
1F 8B
Sources: Apache Tika, Wikipedia, Neil Harvey FileSignatures
All Known Signatures
2 signature variants are documented for .gz files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 1F 8B | 0 | Apache Tika, Wikipedia, Neil Harvey FileSignatures |
| 1F 8B 08 | 0 | Gary Kessler |
Extension
.gz
MIME Type
application/gzip
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .gz files in Python
def is_gz(file_path: str) -> bool:
"""Check if file is a valid GZ by magic bytes."""
signature = bytes([0x1F, 0x8B])
with open(file_path, "rb") as f:
return f.read(2) == signature
How to validate .gz files in Node.js
function isGZ(buffer: Buffer): boolean {
const signature = Buffer.from([0x1F, 0x8B]);
return buffer.subarray(0, 2).equals(signature);
}
How to validate .gz files in Go
func IsGZ(data []byte) bool {
signature := []byte{0x1F, 0x8B}
if len(data) < 2 {
return false
}
return bytes.Equal(data[:2], signature)
}
API Endpoint
/api/v1/gz
curl https://filesignature.org/api/v1/gz
See the full API documentation for all endpoints and parameters.
Frequently Asked Questions
What is a .gz file?
A .gz file is a GZIP archive file file. GZIPcompressed file[61]
What are the magic bytes for .gz files?
The magic bytes for GZIP archive file files are 1F 8B at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .gz file?
To validate a .gz file, read the first bytes of the file and compare them against the known magic bytes (1F 8B) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .gz files?
The primary MIME type for .gz files is application/gzip.
Is it safe to open .gz files?
GZIP archive file (.gz) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.