GZIP archive file (.tgz)
.tgz file signature | application/gzip
The GZIP archive format is a compressed file format created by Jean-loup Gailly and Mark Adler and maintained through the GNU Project. It is commonly used to reduce file size and distribute software packages, source code archives, backups, and Unix tarballs, often as .tgz files. The format is widely supported and generally safe, although archives from untrusted sources can hide unexpected contents or path traversal issues during extraction.
Magic Bytes
Offset 0
1F 8B
Sources: Apache Tika
All Known Signatures
2 signature variants are documented for .tgz files across multiple sources.
| Hex Signature | Offset | Sources |
|---|---|---|
| 1F 8B | 0 | Apache Tika |
| 1F 8B 08 | 0 | Gary Kessler |
Extension
.tgz
MIME Type
application/gzip
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .tgz files in Python
def is_tgz(file_path: str) -> bool:
"""Check if file is a valid TGZ by magic bytes."""
signature = bytes([0x1F, 0x8B])
with open(file_path, "rb") as f:
return f.read(2) == signature
How to validate .tgz files in Node.js
function isTGZ(buffer: Buffer): boolean {
const signature = Buffer.from([0x1F, 0x8B]);
return buffer.subarray(0, 2).equals(signature);
}
How to validate .tgz files in Go
func IsTGZ(data []byte) bool {
signature := []byte{0x1F, 0x8B}
if len(data) < 2 {
return false
}
return bytes.Equal(data[:2], signature)
}
API Endpoint
/api/v1/tgz
curl https://filesignature.org/api/v1/tgz
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .tgz file?
A .tgz file is a GZIP archive file file. The GZIP archive format is a compressed file format created by Jean-loup Gailly and Mark Adler and maintained through the GNU Project. It is commonly used to reduce file size and distribute software packages, source code archives, backups, and Unix tarballs, often as .tgz files. The format is widely supported and generally safe, although archives from untrusted sources can hide unexpected contents or path traversal issues during extraction.
What are the magic bytes for .tgz 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 .tgz file?
To validate a .tgz 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 .tgz files?
The primary MIME type for .tgz files is application/gzip.
Is it safe to open .tgz files?
GZIP archive file (.tgz) 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.