devkult_
tools30converters34

.xz MIME type

XZ filearchives

application/x-xz

LZMA2-compressed files — the .tar.xz archives used by the Linux kernel and many distributions.

MIME typeapplication/x-xz
Extensions.xz
Content-Typeapplication/x-xz
Compress in transit?No — already compressed
File signatureFD 37 7A 58 5A 00 (.7zXZ.)

Good to know

  • Compresses better than gzip and bzip2 at the cost of slow compression; decompression is fast.
  • The 2024 xz-utils backdoor (CVE-2024-3094) was a compromise of the library's release tarballs, not a flaw in the format.

Serve .xz files with the right type

The response header to send:

Content-Type: application/x-xz

Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:

nginx (inside the types block in mime.types)
application/x-xz xz;
Apache (.htaccess or server config)
AddType application/x-xz .xz
Express
res.set("Content-Type", "application/x-xz");
Python
import mimetypes

mimetypes.add_type("application/x-xz", ".xz")
HTML file input
<input type="file" accept=".xz,application/x-xz">

Check it

See what a server sends for a file, and what type a local file really is by its contents:

curl -sI https://example.com/file.xz | grep -i '^content-type:'
file --mime-type file.xz

Frequently asked questions

What is the MIME type for .xz files?

application/x-xz.

What Content-Type header should a .xz file be served with?

Content-Type: application/x-xz. It's already compressed, so servers shouldn't gzip it.

How can I tell if a file is really a .xz?

Check its bytes rather than the extension: XZ files start with FD 37 7A 58 5A 00 (.7zXZ.). On the command line, file --mime-type name.xz does this for you.

Related types

Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options