What is XZ?

Discover what XZ files are, their functionality, and when to use them in this complete guide. Learn about the XZ format and its comparison to others.

Free online file converter tool. Works in Chrome Firefox Safari Edge Opera and other modern browsers on Windows macOS Linux Android and iOS. No software installation or sign-up required. All conversions run directly in your browser, so your files never leave your device. Free to use with no account needed.

XZ

What is XZ?

Complete guide to the XZ file format

Last updated:

Created2009
TypeArchive
Common UseMaximum compression

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 the XZ Format Works

An .xz file wraps LZMA2-compressed data in a structured container consisting of a magic header, one or more independently indexed blocks, and a footer, with integrity checks (commonly CRC32, CRC64, or SHA-256) stored alongside the data.[1] The block index records sizes and offsets, enabling tools to verify and, in multi-block files, partially seek the stream.[1]

History and Standardization

XZ Utils grew out of the earlier LZMA Utils, with Lasse Collin releasing the .xz format and tools around 2009 as a successor that defined a documented container around the LZMA2 algorithm.[2] The project provides both the command-line tools and liblzma, a library many other applications link against for LZMA2 support.[3]

The 2024 Supply-Chain Backdoor

In March 2024 a backdoor (CVE-2024-3094) was discovered in XZ Utils versions 5.6.0 and 5.6.1, inserted by a long-term contributor who had gained maintainer trust; the malicious code in liblzma targeted sshd to enable authentication bypass and remote code execution.[3] It was caught before reaching most stable distributions, but the incident became a landmark case study in open-source supply-chain security.[3]

Technical Details

ProjectXZ Utils (Lasse Collin and others)[1]
File Extension.xz[1]
MIME Typeapplication/x-xz[1]
AlgorithmLZMA2 with CRC64 integrity checking[1]
Multi-threadingYes (pixz, xz --threads)[1]
Typical Compression vs gzip20 to 35% smaller files[1]
Toolsxz command, 7-Zip, WinRAR, most Linux package tools[1]

XZ vs Other Archive Formats

FeatureXZGZBZ27z
Compression algorithmLZMA2[1]DEFLATEBWTLZMA / LZMA2
Compression ratioVery high[3]ModerateHighVery high
SpeedSlowFastModerateSlow
Multiple filesSingle stream[2]Single streamSingle streamYes
Best forMax-ratio single streamsFast compressionBalanced ratioMulti-file archives

XZ delivers high compression on a single stream, trading speed for ratio compared with gzip.

Pros and Cons

Advantages

Excellent Compression Ratio

Typically produces files 20 to 35% smaller than gzip and 10 to 20% smaller than bzip2 for the same input.

Linux Distribution Standard

The default compression format for software packages on Arch Linux, Fedora, and many other distributions.

Data Integrity Checking

Built-in CRC64 checksums verify compressed data integrity, catching corruption before extraction.

Fast Decompression

Despite excellent compression, decompression speed is reasonable and competitive with bzip2.

Disadvantages

Slow Compression

XZ compression is very slow compared to gzip, particularly at high compression levels, requiring minutes for large files.

High Memory Usage

Compression requires significant RAM - high compression levels can use 1 GB or more of memory.

Less Common on Windows

Not as universally known among Windows users as ZIP or 7Z, though 7-Zip supports it fully.

Overkill for Small Files

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 Free

Frequently Asked Questions about XZ

Is XZ better than gzip?

XZ produces significantly smaller files (20 to 35% smaller for typical content) but is much slower to compress. Decompression speed is comparable. For software distribution where files are compressed once and downloaded many times, XZ is the better choice.

How do I decompress an XZ file?

Use: unxz filename.xz - or: xz -d filename.xz - For .tar.xz files: tar -xJf filename.tar.xz

Can I open XZ files on Windows?

Yes. 7-Zip fully supports .xz and .tar.xz files on Windows. WinRAR also supports XZ files.

Why is XZ compression so slow?

XZ uses the LZMA2 algorithm with large compression dictionaries that require analyzing large blocks of data for the best compression. This is computationally intensive. Use the -0 or -1 compression level flags for faster (though less efficient) compression.

What is the difference between XZ and 7Z?

7Z is a container format that can use LZMA/LZMA2 plus other algorithms, supports multiple files with directory structure, and features like AES encryption. XZ is a simpler single-stream LZMA2 format designed for Unix pipeline use. For multi-file archives with the best compression, 7Z is more feature-rich; for Unix/Linux use with TAR, XZ is the standard choice.

References

  1. XZ / LZMA compression - tukaani.org
  2. XZ Utils - tukaani.org
  3. XZ Utils - Wikipedia