XZ Compress & Decompress
Compress and decompress XZ files with LZMA2 at adjustable levels 0-9 via WebAssembly. Built-in CRC64 integrity checking and instant decompression — no uploads.
How to Use
Compress any file into the XZ format or decompress existing .xz and .tar.xz payloads, entirely within your browser via WebAssembly. No uploads, no installations, no file size limits beyond your browser's memory.
Compressing a File
- Select Compress mode using the segmented control at the top. This is the default mode when the tool loads.
- Choose a compression level using the slider. Levels 0-2 prioritize speed with modest ratios; level 6 is the standard default used by the
xzcommand-line tool; levels 7-9 trade processing time and memory for the smallest output. The default is level 6. - Drop or select your file. Any file type is accepted — text files, JSON, executables, TAR archives, images, or any other format.
- Wait for processing. A progress bar tracks the operation. LZMA2 compression is more CPU-intensive than GZIP, so large files at high levels may take several seconds.
- Review results. The tool displays the original size, compressed size, size reduction as a percentage, and total processing time.
- Download the compressed file. Click the download button to save the
.xzfile. The output filename is your original filename with.xzappended, and it decompresses with any standard XZ tool includingunxz, 7-Zip, and liblzma.
Decompressing a File
- Select Decompress mode using the segmented control — or simply drop an
.xzfile while in Compress mode. The tool reads the first six bytes for the XZ magic signatureFD 37 7A 58 5A 00and switches to Decompress automatically. - Drop or select the XZ file. Detection is based on the magic-byte signature, not the extension, so files with missing or wrong extensions are still recognized.
- Review results. The tool displays the compressed size, decompressed size, compression ratio, and processing time. The embedded CRC64 check is verified by the decoder — corrupted archives fail with a clear error instead of producing silently damaged output.
- Download the decompressed file. The output filename defaults to the input name with the
.xzextension stripped. A.txzinput is renamed to.tar; other extensions get a.decompressedsuffix.
About This Tool
The XZ Format
XZ is a general-purpose compressed-file format standardized as the successor to the raw .lzma format. It was designed by the Tukaani project (the team behind XZ Utils) and reached version 1.0 of its file format specification in 2009. Where raw LZMA streams carry only a minimal 13-byte header with no checksums, XZ is a proper container: it wraps the compressed payload in structured headers, block metadata, and per-block integrity verification. This makes .xz files self-describing and corruption-detectable in a way .lzma files never were.
LZMA2: The Engine Inside XZ
XZ compresses data with LZMA2, an incremental update to the original LZMA algorithm created by Igor Pavlov for 7-Zip. LZMA2 keeps the same core machinery — LZ77-style dictionary matching over a large sliding window, Markov-chain context modeling, and a range coder for entropy coding — but chunks the compressed data into blocks that can mix compressed and uncompressed segments. That design lets LZMA2 skip already-compressed data (like JPEG or ZIP content) instead of expanding it, supports faster flushing and seeking, and enables multi-threaded compression in tools that support it. The result: XZ typically produces files 20-40% smaller than GZIP on text, source code, and structured data.
Inside the .xz Container
Every XZ file is a sequence of streams. Each stream opens with a 12-byte header: the 6-byte magic FD 37 7A 58 5A 00 (the bytes \xFD7zXZ\x00), two stream-flag bytes that declare the integrity check type, and a CRC32 over those flags. The body is one or more blocks, each carrying its own compressed size, uncompressed size, filter chain, and check field — CRC32, CRC64 (the default, produced by this tool), or SHA-256. A stream index at the end records the size and location of every block, which is what makes XZ partially seekable: a decoder can verify and skip individual blocks without decompressing the entire file. Multiple streams can also be concatenated into a single .xz file and still decode correctly.
Compression Presets Explained
The levels 0-9 map directly onto the xz -0 through -9 presets and control two things: dictionary size and match-finder depth. Level 0 uses a small dictionary with a fast hash-chain matcher — appropriate for very large inputs or low-end devices. Level 6, the default here and in the xz CLI, uses an 8 MB dictionary that balances ratio and memory for most files. Level 9 uses a 64 MB dictionary with the deepest binary-tree search, squeezing out the last few percent on highly repetitive data at the cost of roughly 10x the compression memory. For typical documents, the gain from level 6 to level 9 is usually 2-6% — worth it for long-term archives, less so for quick transfers.
Why Use This Tool
When to Use XZ Compression
XZ is the standard choice when file size and data integrity matter more than compression speed. Its most common roles:
- Linux package and source distribution — Debian, Fedora, Arch, and most other distributions ship packages as
.tar.xzor XZ-compressed payloads inside.deb/.rpm. The Linux kernel itself has been released as.tar.xzsince 2013. - Archival of logs and database dumps — Highly repetitive text (timestamps, SQL row patterns, JSON keys) compresses exceptionally well. A 1 GB log that GZIP shrinks to ~100 MB often lands near 40-60 MB with XZ at level 9.
- Embedded systems and firmware — SquashFS images, initramfs archives, and kernel images use XZ because flash storage is expensive while decompression stays fast on low-power CPUs.
- Verifiable distribution — Because every block carries a CRC64 check, a corrupted download fails loudly at decode time rather than silently producing damaged files.
- Compressing TAR archives — XZ compresses a single stream, so bundling multiple files means creating a TAR first. Decompress a
.tar.xzhere, then open the result in the TAR Archive & Extract tool.
XZ vs Other Compression Formats
- vs GZIP — XZ compresses 20-40% smaller but is several times slower to compress; decompression speed is comparable. GZIP remains the HTTP/content-encoding standard; XZ wins for distribution and archives.
- vs raw LZMA — Same core codec family and similar ratios, but XZ adds integrity checks, block indexes, and stream concatenation. Prefer .xz for anything stored or shared; .lzma is mostly a legacy format.
- vs Bzip2 — XZ beats Bzip2 on ratio (typically 10-30% smaller) and decompresses much faster. Most projects that used
.tar.bz2have migrated to.tar.xz. - vs Zstandard (zstd) — Zstd reaches similar ratios far faster and is the modern choice for real-time pipelines. XZ still leads for maximum-ratio archival where compression happens once and decompression happens everywhere.
Privacy
Your files never leave your browser. The XZ codec runs as WebAssembly inside your browser tab — no data is sent to any server, no temporary files are created on remote infrastructure, and no third-party services are contacted. This makes the tool safe for compressing sensitive documents, configuration files with credentials, proprietary source code, or any data that must remain private.
Related Tools
Explore other file tools on DevToolkit: LZMA Compress & Decompress for raw .lzma streams, GZIP Compress & Decompress for faster compression with native browser APIs, Bzip2 Compress & Decompress for the Burrows-Wheeler algorithm, TAR Archive & Extract for unpacking .tar.xz results, Hex Dump Viewer for inspecting binary file contents, and File Checksum for verifying file integrity with SHA-256 hashes.