XZ archive file (.xz)
.xz file signature | application/x-xz
XZ is a compressed file format and archiving container developed by the Tukaani project, using the LZMA2 compression algorithm. It is commonly used to reduce the size of software packages, source code archives, and other distribution files, and is supported by many Unix-like utilities and package managers. The format is generally considered safe; its main concern is that decompression can require substantial memory or processing time for large or crafted archives.
Magic Bytes
Offset 0
FD 37 7A 58 5A 00
Sources: Apache Tika, Wikipedia, Gary Kessler
Extension
.xz
MIME Type
application/x-xz
Byte Offset
0
Risk Level
Safe
Validation Code
How to validate .xz files in Python
def is_xz(file_path: str) -> bool:
"""Check if file is a valid XZ by magic bytes."""
signature = bytes([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00])
with open(file_path, "rb") as f:
return f.read(6) == signature
How to validate .xz files in Node.js
function isXZ(buffer: Buffer): boolean {
const signature = Buffer.from([0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00]);
return buffer.subarray(0, 6).equals(signature);
}
How to validate .xz files in Go
func IsXZ(data []byte) bool {
signature := []byte{0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}
if len(data) < 6 {
return false
}
return bytes.Equal(data[:6], signature)
}
API Endpoint
/api/v1/xz
curl https://filesignature.org/api/v1/xz
See the full API documentation for all endpoints and parameters.
Related Formats
Frequently Asked Questions
What is a .xz file?
A .xz file is a XZ archive file file. XZ is a compressed file format and archiving container developed by the Tukaani project, using the LZMA2 compression algorithm. It is commonly used to reduce the size of software packages, source code archives, and other distribution files, and is supported by many Unix-like utilities and package managers. The format is generally considered safe; its main concern is that decompression can require substantial memory or processing time for large or crafted archives.
What are the magic bytes for .xz files?
The magic bytes for XZ archive file files are FD 37 7A 58 5A 00 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.
How do I validate a .xz file?
To validate a .xz file, read the first bytes of the file and compare them against the known magic bytes (FD 37 7A 58 5A 00) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.
What is the MIME type for .xz files?
The primary MIME type for .xz files is application/x-xz.
Is it safe to open .xz files?
XZ archive file (.xz) 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.