Convert GZ to XZ

Converting GZ to XZ recompresses the same bytes with a far stronger engine: gzip’s DEFLATE searches a 32 KB window, while XZ’s LZMA2 works with a dictionary of up to 64 MB and finds repetition gzip cannot reach. On text the saving is substantial, on already-compressed contents it is nothing, and the price is paid in compression time and in the memory needed to unpack it again.

  • Where it runs On our server, because a browser cannot run the software this needs.
  • Lossless Nothing is discarded. The XZ holds exactly what the GZ held.
  • File size limit Up to 25 MB per file, free, without an account.
  • Worth knowing The files come out byte for byte. What does not survive is anything the container held about them rather than in them — a password, and on some formats the original permissions and timestamps.

Up to 100 files at once. Mixed formats are fine.

The storage bill that turns a pile of GZ files into XZ

Nobody converts a gzipped file they are about to open. The reader here is looking at something that has accumulated: a year of rotated application logs, nightly database dumps kept for compliance, a research dataset that has to stay available and is read once a quarter, CI artefacts nobody has deleted. Gzip was the right choice when the files were written — it is fast, it is everywhere, and it was already in the log rotation config — and it is not the right choice for the second half of the file’s life.

That distinction is the whole decision. Gzip optimises for the moment of writing and reading; XZ optimises for the years in between. If the archive is going to be fetched and unpacked by something in a hurry, or by a device with very little memory, leave it as it is. If it is going to sit in cold storage and be read almost never, the conversion is close to free money, and it is worth doing across the whole folder rather than one file at a time.

Thirty-two kilobytes against sixty-four megabytes

The number in the registry is the entire explanation. Gzip, standardised as RFC 1952 in May 1996, uses DEFLATE with a 32 KB history window: when it is compressing byte one million, it can see back to byte nine hundred and sixty-eight thousand and no further. Anything that repeated earlier than that is compressed again from scratch, as though it had never been seen. XZ, from 2009, carries a dictionary the registry records at up to 64 MB — two thousand times the reach.

That is why the gain is enormous on some inputs and zero on others. A year of log lines repeats the same forty message templates for gigabytes, and gzip rediscovers each of them thousands of times while XZ learns them once. A SQL dump repeats column names on every row. Source trees repeat licence headers, imports and boilerplate across hundreds of files. Against that, a GZ holding a photograph or a video has no long-range repetition to find, because the redundancy was removed by JPEG or H.264 before gzip ever saw it, and the strongest compressor in the world cannot invent structure that is not there.

What the stronger compressor charges you for

Compression time is the obvious cost and the least important one, because it is paid once by a machine that is not waiting for you. XZ is dramatically slower than gzip at the same task — that is the direct consequence of searching a dictionary two thousand times larger — and for a job you run overnight across a storage bucket, that is simply not a problem worth optimising.

Memory at decompression is the cost that actually decides things, and it is the one people miss. Gzip needs its 32 KB window to unpack, which is to say nothing at all; XZ needs a buffer scaled to the dictionary the file was written with. On a laptop or a server that is unremarkable. On a router, a small embedded device, a memory-capped container or a build agent with tight limits, it is the difference between the archive opening and the process being killed. Check the machine that will unpack the file, not the one that compresses it.

The TAR that appears even when there was only one file

Both formats compress exactly one stream, so neither knows what a directory is. In practice a `.gz` is almost always a `.tar.gz`: a TAR carrying the names and the folders, with gzip wrapped around it. The conversion takes both layers off, then puts both back — the members are collected into a fresh TAR and that TAR is compressed with xz.

The case worth knowing about is the one where the source was not a tarball. A plain `access.log.gz` holds one ordinary file, and the repack still builds a TAR around it, so what comes back is a tarball containing `access.log` rather than a bare compressed file. That is harmless if you unpack it with `tar xJf` and confusing if you reach for `unxz` and find a file called `output.tar`. If your tooling expects a single compressed stream with nothing wrapped around it, this is the detail to plan for.

The file name gzip remembered and XZ will not

A gzip stream has a header field for the original file name, which is why decompressing `dump.gz` on a Unix machine can hand you back `dump.sql` even though nothing in the extension said so. XZ has no such field. It stores an integrity check and nothing about where the data came from.

That has a practical consequence at both ends of this conversion and it caused a real bug in this converter, recorded in the code: because gzip stores a name and xz does not, an inner tarball arrives from a GZ called something sensible and from an XZ called whatever the extractor chose. The fix was to force the tar type rather than infer it from the name. For you, the lesson is simpler — the extension you put on the downloaded XZ is the only label it will ever carry, so name it `something.tar.xz` and mean it.

Integrity checks on a gzipped stream and on an xz one

Both formats verify themselves, which is one of the reasons this conversion is safe to run unattended. A gzip stream ends with a CRC-32 and the uncompressed length; an XZ stream carries its own check, CRC-64 by default, over the uncompressed data. In both cases a truncated download or a flipped bit produces an error on decompression rather than a file that quietly reads short.

What neither can do is tell you which file is damaged, because at that layer there are no files. A ZIP or a 7Z records a checksum per entry and can report that one member of forty is corrupt; a compressed stream can only report that the stream is corrupt. If per-member integrity is what you need from an archive — because you intend to recover the rest when one part rots — then a stream compressor is the wrong shape for the job regardless of how well it compresses.

Where the gzipped archive goes to be recompressed

This conversion does not run on your device. Most tools on this site keep the file local and say so; repacking archives is one of the exceptions, because it needs 7-Zip and xz as real programs. The file goes over an encrypted connection to a container that runs them, and the container has no outbound internet access of its own.

Each job gets a scratch directory on a memory-backed filesystem, and that directory is deleted as soon as the job ends regardless of whether it succeeded. Anything still running after sixty seconds is killed — a malformed archive puts a compressor in a loop far more often than it makes one fail. The free tier accepts 25 MB per uploaded file, which for a gzipped log archive is a great deal of text but is a real ceiling on a dataset.

Deciding between XZ and BZ2 for the same gzipped input

BZ2 is the other traditional answer to "gzip is not compressing this enough", and on most text it now loses to XZ on both axes at once — a worse ratio and slower decompression. The registry marks BZ2 as legacy for that reason. Its one remaining advantage is the flip side of the memory point above: bzip2 works in blocks of up to 900 KB, so unpacking one never needs much memory at all.

So the choice is not really about ratio. Pick XZ when the machine that will unpack the archive is an ordinary computer, which it usually is, and pick BZ2 only when it is not — an old appliance, a constrained container, a system where xz is genuinely not installed and cannot be. Choosing BZ2 for its compression alone is a decision from about 2005 that has not been true for a long time.

Measuring the saving before you convert the whole folder

Do one file first and look at the two sizes. A single representative archive tells you what the rest of the folder will do far more reliably than any rule of thumb, because the answer is decided by the contents rather than by the formats — the same conversion that halves a log archive does nothing at all to a folder of photographs. If the first file barely moves, stop; you have learned that the data has no long-range redundancy and no compressor is going to find any.

Then check the listing rather than only the size. Run `tar tJf` on the result and compare the entry count and the paths against what the GZ held, particularly the top level: an archive packed from inside a directory and one packed from its parent differ by a leading folder in every path, and that difference breaks scripts long after anyone remembers converting anything. Once the listing matches and the size is what you expected, the original has no job left to do.

How to recompress a GZ file as XZ

  1. Drop the GZ or .tar.gz file onto this page, or click to choose one.
  2. It is decompressed, re-tarred and compressed again with xz on our server.
  3. Compare the two sizes, check the listing with tar tJf, then retire the GZ.

GZ and XZ: a 32 KB window against a 64 MB dictionary

GZ compared with XZ
GZXZ
Full nameGzip ArchiveXZ Archive
File extension.gz, .tgz.xz
Media typeapplication/gzipapplication/x-xz
CompressionLossless — nothing is discardedLossless — nothing is discarded
First published19922009
SpecificationRFC 1952
LicensingOpen standardOpen standard
Standing todayCurrentCurrent
Opens in a browserNo browserNo browser
Considered insteadBZ2, ZIPBZ2, 7Z

What survives

Nothing is discarded. GZ and XZ both store their content losslessly, so the conversion is a change of packaging rather than a change of quality, and it can be repeated without accumulating damage.

Opening the result

7-Zip and Keka read both GZ and XZ, so there is a way to check the result against the original without a second tool.

File size and quality

XZ works over 8 MB at a time against GZ's 32 KB — that is the span a repetition has to fall inside before it can be compressed away. It is where the difference in ratio comes from, and where the extra time goes.

What each format is for

GZ was published in 1992. The specification is RFC 1952, and it is worth reading if the file has to outlive the tool that wrote it.

XZ dates from 2009. xz, 7-Zip and Keka all read it.

GZ was published in 1992 and XZ in 2009. The older one is generally the safer file to hand to somebody; the newer one usually does the job in fewer bytes.

GZ to XZ: how much you save and what it costs

Are my GZ files uploaded anywhere?

Yes — this conversion needs software that cannot run in a browser, so the file is uploaded over an encrypted connection. It is deleted as soon as the job finishes, and the result is sent straight back to you without being stored. The work is done by 7-Zip, the archiver, in its command-line form.

How much smaller will the XZ actually be?

It depends entirely on what is inside, and the range is wide. On text — logs, SQL dumps, CSV, source code — the gain is usually large, because gzip only looks back 32 KB while XZ can look back 64 MB and finds repetition gzip could not reach. On a GZ that holds a JPEG, an MP4 or an already-compressed database file, expect no useful change at all.

What does the extra compression cost me?

Time and memory, both mostly at compression. XZ is markedly slower to compress than gzip and it needs memory proportional to its dictionary. Decompression is much cheaper than compression but still needs a dictionary-sized buffer, where gzip needs 32 KB, so a very small device that unpacks the file is the case to check before you commit.

I sent a single gzipped file and got back a tarball. Why?

Because XZ compresses one stream and the repack always builds a TAR before compressing. A `.tar.gz` comes apart into its files and is re-tarred, which is what you wanted; a plain `notes.txt.gz` also gets a TAR wrapped around it, so the result holds `notes.txt` inside a tarball rather than on its own. Unpack it with `tar xJf` rather than `unxz`.

Is anything inside the files changed?

No. Both formats are lossless, so every byte that went into the GZ comes back out of the XZ. What can be lost is information the old container held about the files rather than in them — an original file name gzip recorded, and on some paths the permissions and timestamps.

How big a GZ can I convert here?

25 MB on the free tier, measured on the file you upload. This pair runs on our server rather than in your browser, and the archive is refused before it is opened if it declares that it expands to more than 2 GB — which a compressed log archive can genuinely do.

Should I keep the GZ as well?

Until you have opened the XZ and compared the listing, yes. After that there is no reason to: the conversion is lossless and keeping both defeats the purpose of doing it. Check the file count and the paths first, because that is where a repack goes wrong, not in the bytes.

More about these formats