ZIP, 7z, TAR, GZ: archive formats and when repacking helps
3 min read · Updated 2026-09-12
Archive formats do two separable jobs: bundling many files into one, and compressing data to make it smaller. Some formats do both. Some do only one. Most confusion about archives — including why `.tar.gz` has two extensions — comes from not separating those jobs.
Bundling and compressing are different jobs
TAR bundles. It concatenates files and their metadata into a single stream, and compresses nothing at all. A .tar file is roughly the same size as the files inside it.
GZ, BZ2, XZ, and ZST compress. Each takes one stream of bytes and makes it smaller. They have no concept of a file name, a directory, or multiple entries — a .gz holds exactly one compressed thing.
That is why `.tar.gz` exists: TAR bundles the files into one stream, then GZIP compresses that stream. Two tools, two extensions, composed in the Unix tradition. The same logic gives you `.tar.bz2`, `.tar.xz`, and `.tar.zst`.
ZIP and 7z do both jobs in one format: they hold many files and compress each of them. This is why they are the formats people actually hand to each other, and why TAR is mostly seen in Unix and developer contexts.
What each one is good at
| Format | Character |
|---|---|
| ZIP | Universal. Every operating system opens it with no extra software. Modest compression. |
| 7z | Much better compression than ZIP, especially on large or repetitive data. Needs software on Windows and macOS. |
| TAR | Bundling only, no compression. Preserves Unix permissions and symlinks. |
| GZ | Fast, ubiquitous, single-stream. The default for web transfer and log rotation. |
| BZ2 | Smaller than GZ, noticeably slower. Largely superseded. |
| XZ | Very high compression, slow. Common for source tarballs and OS images. |
| ZST (Zstandard) | Near-GZ speed with much better ratios. The modern choice where both ends support it. |
When repacking actually saves space
Compression works by finding redundancy. If the data has already had its redundancy removed, there is nothing left to find.
So a ZIP full of JPEGs, MP3s, MP4s, or PDFs will barely shrink at all when converted to 7z — those files are already compressed, and a second pass over compressed data gains a percent or two at best. People are often surprised by this and conclude the conversion did not work. It worked; there was simply nothing there.
Repacking pays off on uncompressed or highly repetitive data: text files, logs, CSVs, source code, database dumps, BMP or WAV files, and directories full of near-identical files. On a large log archive, ZIP to 7z or XZ can genuinely halve the size.
What the conversion does
Repacking is not a rewrite of the archive's container — every file inside is fully decompressed and then compressed again with the new algorithm. The contents come out byte-identical; only the archive's size changes.
All of this happens inside a temporary working directory that is removed afterwards even if the job fails, so nothing is left behind on the server.
Two constraints follow from the bundling/compressing split. Converting a multi-file archive into a single-file compression format — a ZIP with forty files into a .gz — only works if the archive contains exactly one file; otherwise the job stops with a clear error rather than silently dropping the rest. And going the other way, a .gz converted to ZIP is decompressed to a temporary file and packed as that archive's single entry.
RAR and ISO are read-only
RAR is a proprietary format. Its decompression is documented enough to read, but creating one requires the commercial tool. So a .rar can be opened and its contents repacked as ZIP or 7z, and nothing here will write a .rar back out.
ISO is a disc image rather than an archive, and the same applies: its contents can be read and repacked, but it is not a write target.
If someone sends you a RAR and you need to pass it on, converting it to ZIP is the courteous move — the recipient will not need to install anything.
Practical guidance
- Sending files to another person: ZIP. It opens on every machine with no software and no instructions. This is worth more than the space 7z would save.
- Archiving a large amount of text or source data for yourself: 7z or tar.xz. The compression difference is real when the data is compressible.
- Sending to a Linux server or a build pipeline: tar.gz, or tar.zst if both ends support it. TAR also preserves permissions and symlinks, which ZIP handles poorly.
- Bundling already-compressed media: use ZIP with no expectations. You are bundling, not compressing, and that is fine — a single download is the point.
- Passing on a RAR: convert to ZIP first.