Skip to content
DevToolKit

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.

Drop any file to compress with XZ

Any file type accepted — compressed using LZMA2 in the XZ container format

0 Fastest6 Standard9 Smallest
Client-Side XZ Compression

This tool uses the XZ container format powered by LZMA2 — the same compression engine behind .tar.xz packages and the xz command-line tool. All processing runs in your browser via WebAssembly. No files are uploaded. Drop an .xz file and the tool auto-switches to decompress mode.

Processed locally
Was this tool helpful?

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

  1. Select Compress mode using the segmented control at the top. This is the default mode when the tool loads.
  2. Choose a compression level using the slider. Levels 0-2 prioritize speed with modest ratios; level 6 is the standard default used by the xz command-line tool; levels 7-9 trade processing time and memory for the smallest output. The default is level 6.
  3. Drop or select your file. Any file type is accepted — text files, JSON, executables, TAR archives, images, or any other format.
  4. 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.
  5. Review results. The tool displays the original size, compressed size, size reduction as a percentage, and total processing time.
  6. Download the compressed file. Click the download button to save the .xz file. The output filename is your original filename with .xz appended, and it decompresses with any standard XZ tool including unxz, 7-Zip, and liblzma.

Decompressing a File

  1. Select Decompress mode using the segmented control — or simply drop an .xz file while in Compress mode. The tool reads the first six bytes for the XZ magic signature FD 37 7A 58 5A 00 and switches to Decompress automatically.
  2. 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.
  3. 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.
  4. Download the decompressed file. The output filename defaults to the input name with the .xz extension stripped. A .txz input is renamed to .tar; other extensions get a .decompressed suffix.

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.xz or XZ-compressed payloads inside .deb/.rpm. The Linux kernel itself has been released as .tar.xz since 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.xz here, 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.bz2 have 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.

FAQ

What is the difference between XZ and LZMA?
XZ is a container format that wraps the LZMA2 compression stream with a proper header, CRC64 integrity checks, and support for concatenated streams and filters. Raw .lzma files use the older LZMA1 format with a minimal 13-byte header and no checksums. Files produced by this tool are standard .xz archives readable by the xz command-line tool, 7-Zip, and all modern archiving software.
What do the compression levels 0-9 mean?
Levels control the dictionary size and search depth, mirroring the xz -0 through -9 presets. Level 0 uses a small dictionary tuned for maximum speed with modest ratios. Level 6 — the same default as the xz command-line tool — uses an 8 MB dictionary for a balanced tradeoff. Level 9 uses a 64 MB dictionary with the deepest match search for the smallest output, at the cost of more memory and processing time.
How does XZ compare to GZIP?
XZ typically produces files 20-40% smaller than GZIP on text, source code, and structured data because LZMA2 uses a much larger dictionary and a range coder instead of DEFLATE's 32 KB window and Huffman coding. Compression is slower, but decompression speed is comparable — which is why Linux distributions, kernel source releases, and many package managers distribute archives as .tar.xz.
Can I decompress .tar.xz files?
Yes. Decompressing a .tar.xz file produces the inner .tar archive. After downloading it, open the TAR Archive & Extract tool to browse and extract the individual files inside. The two-step approach mirrors how tar.xz works on the command line: xz handles compression, tar handles bundling.
Are my files uploaded to a server?
No. Compression and decompression run entirely in your browser using a WebAssembly build of the XZ codec. No network requests are made during processing and no data leaves your device, so the tool is safe for sensitive documents, credentials, and proprietary data.