Skip to main content

XZ Compress & Decompress

API reference

Compress text into an .xz stream as Base64 or hex, or decompress Base64/hex .xz data back to text — encoding auto-detected, checksum verified, with size and ratio stats. Runs in your browser; nothing is uploaded.

Input

When decompressing, Base64 and hex are both accepted — the encoding is detected for you.

Output

Output
Stats
PropertyValue
No data yet
Was this helpful?

More ways to use this tool

REST API

curl -X POST https://api.iotools.cloud/v1/tool/xz-compression \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "mode": "compress",
    "inputText": "Compression loves repetition. Compression loves …",
    "level": "6",
    "outputEncoding": "base64"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `xz-compression` tool (XZ Compress & Decompress) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Embed widget

<iframe
  src="https://iotools.cloud/embed/xz-compression/"
  width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
  title="XZ Compress & Decompress — iotools.cloud"
  sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
  allow="clipboard-write"
  style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>

Drop this into your own page — free, no key required, just a link back.

Cost per API/MCP callFrom 5 credits
Need more credits?View pricing

Also available with

Guides

Compress a piece of text into an .xz stream, or paste .xz data and get the original text back. Because a text box can't hold raw binary, the compressed side is written as Base64 or hex. When you decompress, paste either one: the tool works out which encoding you used.

How to use it

  1. Pick a Mode: Compress or Decompress.
  2. Paste your text (to compress) or your Base64 / hex .xz data (to decompress) into Input. The result updates as you type.
  3. When compressing, choose a Compression level and an Output encoding: Base64, lowercase hex or uppercase hex.
  4. Copy or download the Output. The Stats table shows the sizes before and after, the ratio, and, when decompressing, which encoding was detected and which integrity check passed.

What is XZ?

XZ is the compressed format written by xz (XZ Utils), the tool behind .tar.xz source archives and most Linux package formats. It wraps LZMA2 compressed data in a container that also stores a checksum, usually CRC64, so corruption is caught on the way out. This tool produces the same container as xz -c: what you compress here decodes with unxz or xz -d, and data made by xz decompresses here.

Compression levels

The levels match xz -0 to xz -9. Level 6 is the xz default. Higher levels use a bigger dictionary, which only helps when the input is large and repetitive. For a few sentences, every level gives about the same size.

Why is my compressed output bigger than the input?

An .xz stream carries a fixed overhead of about 60 bytes: a header, block and index records, a footer and a checksum. Short text can't save enough to cover that, so the "smaller" figure goes negative. Compression pays off from a few hundred bytes of text, and the more repetition the better.

What happens if the data is damaged?

Decompression checks the stream's own checksum. If the data was cut short or changed, you get an error instead of silently wrong text. If you paste a different format by mistake, such as gzip, 7z or lzip data, the error names that format. If the decompressed bytes aren't valid UTF-8 text, the output is shown as Base64 so nothing is lost.

Privacy

Compression runs in your browser with a WebAssembly build of the LZMA codec. Your text is never uploaded.

To compress or extract whole .xz or .tar.xz files, use the XZ File Compressor & Extractor. For the older .lzma format, use LZMA Compress & Decompress, and for lzip streams, Lzip Compress & Decompress.

unxzlzma2xz-utilscompress textdecompressbase64hextar.xz

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.