XZ Compress
Compress text with XZ. Output is Base64 or hex.
Compress text with XZ (LZMA2) in your browser. Free, offline, runs entirely client-side. Read more Show less
What is XZ compression?
XZ is a container format built around the LZMA2 compression algorithm. It is developed and maintained by the Tukaani Project and specified in the xz file format specification. XZ is one of the two formats that share the name "LZMA" in everyday use - the other is LZMA-Alone, which is a raw stream with no container.
XZ is used for software distribution (tarballs, Linux kernel releases, Docker images), for backups, and anywhere the best possible compression ratio matters more than compression speed. It often beats gzip and bzip2 by 20-40 percent on text data.
How to use
Type or paste text and press Compress. The tool produces a Base64 or hex representation of the compressed bytes. Copy that string to reuse it elsewhere, or use it with the XZ Decompress tool.
All compression happens in your browser. Nothing is uploaded.
Compression levels
XZ supports preset levels from 0 (fastest, larger output) to 9 (slowest, smallest output). This tool exposes a subset:
Level 0-3 - fast. Good for real-time compression where CPU is the bottleneck.
Level 4-6 - balanced. Default is 6.
Level 7-9 - maximum compression. Slow, useful for archival where the data is compressed once and decompressed many times.
FAQ
XZ vs LZMA-Alone
XZ wraps LZMA2 in a container with a header, checksums (CRC32, CRC64, or SHA-256), and optional stream padding. LZMA-Alone is the raw compressed stream with no container. Use XZ for files; use LZMA-Alone when embedding compressed data inside another format that already provides framing.
Why does my compressed output look longer than the input?
Because for very small inputs, the XZ container header (about 12-24 bytes) plus the compressed stream can exceed the original size. This is normal. For inputs under ~50 bytes, XZ provides no benefit.
Is XZ the same as 7-zip?
No. 7-zip is a container format that can use LZMA, LZMA2, or other compressors. XZ is a container format that always uses LZMA2. 7-zip can extract XZ files; XZ tools cannot extract 7-zip archives.
What is the maximum input size?
This tool has no hard limit, but the WebAssembly module needs enough memory for the dictionary plus the data. Practical limit for a browser is a few hundred megabytes. For very large files, use the xz command-line tool.
Command line equivalent
# Compress
xz -zk9 input.txt # keeps original, level 9
echo "hello" | xz | base64
# Decompress
xz -dk input.txt.xz
echo "BASE64_DATA" | base64 -d | xz -d
# Levels: -0 (fastest) to -9 (best)
# XZ container can carry CRC32, CRC64, or SHA-256 checksums.