What is XZ?
Complete guide to the XZ file format
Last updated:
What is XZ?
XZ is a lossless data compression format using the LZMA2 algorithm, developed as part of the XZ Utils project in 2009. It provides excellent compression ratios that are competitive with 7-Zip's LZMA format, significantly outperforming both gzip and bzip2. XZ has become the preferred compression format for many Linux distributions including Fedora, Arch Linux, and Debian for distributing software packages, because the better compression ratios reduce download sizes for users.
The XZ format uses LZMA2 compression in a container designed for long-term data integrity, including CRC64 checksums for data verification. Compression is multi-threaded in modern implementations, which addresses the historical weakness of LZMA-based formats. Decompression is fast compared to compression - XZ decompresses at speeds comparable to bzip2 despite its much better compression ratio, making it practical for package distribution where files are compressed once and decompressed many times.
How XZ Works
An .xz file is produced by the XZ Utils compressor, and its appeal is a very high compression ratio. Like gzip and bzip2 it is a single-file stream compressor, not an archiver, so a directory is bundled first by tar to make a .tar.xz. What sets XZ apart is the algorithm underneath it: LZMA2, a refined version of the LZMA method made famous by the 7-Zip archiver.
LZMA is a dictionary compressor in the LZ77 family, but a very sophisticated one. It searches for repeated sequences using a large sliding window, often many megabytes, so it can find redundancy across long distances that gzip's small window would miss entirely. It then encodes the results with a range coder, a form of arithmetic coding that packs symbols even more tightly than the Huffman coding older formats use, and it adapts its statistical model as it goes.
The .xz container wraps this LZMA2 stream with a structured header and footer, integrity checks (it can use CRC-32, CRC-64, or SHA-256), and support for multiple independent blocks. Those blocks allow limited random access and multi-threaded compression, and the integrity fields make XZ suitable for long-term archives where silent corruption must be caught.
XZ offers presets from 0 to 9, with an extra e (extreme) modifier. Higher presets use a larger dictionary and search harder, producing smaller files but demanding substantially more time and memory, sometimes hundreds of megabytes of RAM at the top settings. Decompression, by contrast, is fast and light, which fits the compress-once, distribute-widely use case perfectly.
History and Standardization
XZ Utils grew out of the earlier LZMA SDK created by Igor Pavlov for 7-Zip. The .xz format and its command-line tools were developed to bring LZMA compression to the Unix world in a clean, streamable container, replacing an earlier and now deprecated format called .lzma.
The format is openly specified and the reference implementation is in the public domain, which made adoption frictionless. Linux distributions embraced it for package archives and kernel images because the smaller downloads meaningfully reduced mirror bandwidth, and it became a common choice for shipping source tarballs as .tar.xz.
Today XZ is a standard tool on essentially every Linux and BSD system and is supported by all major cross-platform archive utilities. It occupies the niche of maximum practical compression for distribution, where the extra encode time is paid once by the publisher and every downloader benefits from the smaller file.
XZ Compared to Gzip, Bzip2, and Zstandard
Against gzip and bzip2, XZ generally wins on size. It typically produces the smallest file of the three and, unlike bzip2, decompresses quickly. The cost is compression time and memory: building a high-preset .xz is slow and RAM-hungry, so XZ is best when the file is created once and read many times.
The modern trade-off is against Zstandard (zstd). At its highest levels zstd can approach XZ's ratio while compressing far faster, and it decompresses faster too. Where raw speed matters, zstd is often preferred; where the absolute smallest file is the goal and encode time is not a concern, XZ still tends to edge ahead. Many projects now offer both.
As with every stream compressor here, XZ is not an archiver. A lone .xz is one compressed file with no directory structure or permissions preserved, which is why it almost always appears as .tar.xz. That pairing, tar for structure and XZ for size, is a common default for Linux software distribution.
Technical Details
XZ vs Other Archive Formats
| Feature | XZ | GZ | BZ2 | 7z |
|---|---|---|---|---|
| Compression algorithm | LZMA2[1] | DEFLATE | BWT | LZMA / LZMA2 |
| Compression ratio | Very high[3] | Moderate | High | Very high |
| Speed | Slow | Fast | Moderate | Slow |
| Multiple files | Single stream[2] | Single stream | Single stream | Yes |
| Best for | Max-ratio single streams | Fast compression | Balanced ratio | Multi-file archives |
XZ delivers high compression on a single stream, trading speed for ratio compared with gzip.
Pros and Cons
Advantages
Typically produces files 20 to 35% smaller than gzip and 10 to 20% smaller than bzip2 for the same input.
The default compression format for software packages on Arch Linux, Fedora, and many other distributions.
Built-in CRC64 checksums verify compressed data integrity, catching corruption before extraction.
Despite excellent compression, decompression speed is reasonable and competitive with bzip2.
Disadvantages
XZ compression is very slow compared to gzip, particularly at high compression levels, requiring minutes for large files.
Compression requires significant RAM - high compression levels can use 1 GB or more of memory.
Not as universally known among Windows users as ZIP or 7Z, though 7-Zip supports it fully.
The overhead of LZMA2 processing provides minimal benefit for small files where gzip is fast and adequate.
When to Use XZ
Here are the most common situations where XZ is the right choice:
Linux Package Distribution
The standard format for distributing compressed packages on Arch Linux (pacman uses .pkg.tar.xz) and many Fedora packages.
Source Code Archives
Many major open-source projects (Linux kernel, GNU packages) distribute source as .tar.xz for the best download size.
Large File Compression
Use xz when compressing large databases, log archives, or backup files where storage savings justify slower compression.
Long-Term Storage
The built-in integrity checking and high compression make xz a good choice for archival storage.
Convert XZ Files
Need to convert your XZ files? Use our free online converter.
Try Archive Converter FreeHow to open a XZ file
XZ files are compressed archives commonly used for distributing software and data. There are various software options available for handling XZ files, including professional tools, free and open-source programs, browser-based solutions, and built-in utilities in operating systems. Professional tools tend to offer advanced features and support, while free and open-source options are suitable for users who need basic functionality without cost. Browser-based tools provide convenience for quick access, while built-in utilities are often sufficient for casual users.
When choosing software for XZ files, several factors come into play, such as feature fidelity, whether the user needs to edit or simply view the content, and the cost model of the software. Platform compatibility is also crucial, as some tools may only be available on specific operating systems. Additionally, users should consider export needs and whether converting the XZ file to another format is more beneficial for their workflow.
7-Zip 21.07
7-Zip is a free and open-source file archiver that supports a wide range of formats, including XZ. It allows users to create, extract, and manage XZ files with high compression ratios and strong encryption options. The software maintains high fidelity when handling XZ files, ensuring that the original data is preserved during extraction.
- Create and extract XZ archives
- High compression ratio support
- Strong AES-256 encryption
- Command-line interface for automation
- Integration with Windows Explorer
- Completely free and open-source
- Excellent compression performance
- Supports a wide range of formats
- User interface may feel outdated
- Limited support for advanced editing
Exports to: ZIP, TAR, GZ, BZ2
Best for: 7-Zip is ideal for users seeking a powerful, free tool for managing XZ files with strong compression capabilities.
Visit 7-Zip →WinRAR 6.20
WinRAR is a popular file archiver that supports XZ files among many other formats. It provides a user-friendly interface and robust features for compressing and decompressing files. WinRAR maintains high fidelity during extraction and offers additional functionalities like file recovery and repair.
- Create and extract XZ archives
- File recovery and repair tools
- Multi-volume archives support
- Customizable compression settings
- Integration with Windows context menu
- User-friendly interface
- Strong recovery options
- Widely recognized and trusted
- Paid software after trial period
- Limited support for Linux users
Exports to: ZIP, TAR, GZ, RAR
Best for: WinRAR is suitable for users who prefer a polished interface and advanced features for handling XZ files, especially in a Windows environment.
Visit WinRAR →PeaZip 9.2.0
PeaZip is a free and open-source file manager and archiver that supports XZ files. It offers a comprehensive set of features for creating and extracting archives, with a focus on security and usability. PeaZip ensures fidelity when dealing with XZ files and provides a modern interface.
- Create and extract XZ archives
- Secure file deletion options
- Multi-platform support
- Batch processing capabilities
- Customizable user interface
- Cross-platform compatibility
- Strong focus on security features
- User-friendly modern interface
- Less known than competitors
- Fewer advanced features than WinRAR
Exports to: ZIP, TAR, ARC, 7Z
Best for: PeaZip is perfect for users looking for a free, secure, and user-friendly tool for managing XZ files across multiple platforms.
Visit PeaZip →The Unarchiver 4.3.1
The Unarchiver is a free macOS application designed to handle various archive formats, including XZ. It focuses on simplicity and ease of use, allowing users to quickly extract files from XZ archives without any complex settings. The Unarchiver maintains high fidelity during extraction, ensuring data integrity.
- Extract XZ files effortlessly
- Supports many archive formats
- Integration with Finder
- Automatic file association
- Simple drag-and-drop functionality
- Extremely easy to use
- Lightweight and fast
- Seamless macOS integration
- Limited to extraction only
- No advanced features for compression
Exports to: N/A
Best for: The Unarchiver is ideal for macOS users who need a straightforward tool for quickly extracting XZ files without additional complexities.
Visit The Unarchiver →