Skip to content
Aback ZIP

Formats · 4 min read · Updated

ZIP vs TAR: what is the difference?

TAR bundles files, gzip compresses them, ZIP does both file by file. Learn how ZIP, .tar and .tar.gz differ and when each is the better choice.

ZIP and TAR both turn many files into one, but they come from different worlds. ZIP grew up on PCs and compresses each file as it adds it. TAR grew up on Unix and only bundles; compression is applied afterwards by a separate tool, which is where names like .tar.gz come from.

How TAR works

TAR (tape archive) dates back to 1979 Unix and was designed for writing to tape. It stores each file as a 512-byte header followed by the file's data, one after another, with no index at the end. A plain .tar file is not compressed at all.

To compress it, the whole TAR stream is passed through a compressor:

  • .tar.gz or .tgz: gzip (Deflate), the most common
  • .tar.bz2: bzip2, smaller but slower
  • .tar.xz: xz (LZMA2), smaller still
  • .tar.zst: Zstandard, fast with good ratios

How ZIP works

ZIP compresses each file individually and writes an index, the central directory, at the end of the archive. A reader can list the contents and pull out a single file without touching the rest. See What is a ZIP file? for the details.

Key differences

FeatureZIPTAR + gzip
CompressionPer file, built inWhole archive, by a separate compressor
Many small, similar filesGood ratioOften a little better, because files are compressed together
Listing contentsFast; reads the indexMust decompress and read the whole stream
Extracting one fileFastMust read through everything before it
DamageUsually limited to the affected fileCan make everything after the damaged point unreadable
Unix permissions and symlinksSupported by some tools; ownership usually not keptFully supported; the format was built for it
StreamingPossible, but the index is written lastNatural; designed for pipes and tapes
Built-in supportWindows, macOS, Linux, iOS, AndroidLinux and macOS; Windows 10 and 11 via the tar command; recent Windows 11 in File Explorer

Common commands

# ZIP
zip -r archive.zip folder/
unzip -l archive.zip
unzip archive.zip -d destination/

# TAR + gzip
tar -czf archive.tar.gz folder/
tar -tzf archive.tar.gz
tar -xzf archive.tar.gz -C destination/

In tar, c creates, x extracts, t lists, z uses gzip and f names the archive file. The folder given to -C must already exist. GNU tar and bsdtar detect the compression when extracting, so tar -xf archive.tar.gz works too.

Which should you use?

  • Sharing with people on Windows, Macs or phones: ZIP.
  • Linux software, source releases and server backups: .tar.gz or .tar.xz, because they keep permissions and symlinks and every Unix system has tar.
  • Frequently grabbing single files from a big archive: ZIP, thanks to its index.
  • Squeezing many small text files as small as possible: .tar.xz usually beats ZIP.

Converting between ZIP and TAR

TAR to ZIP turns .tar, .tar.gz or .tgz files into a ZIP that opens natively on Windows and macOS, keeping folders and timestamps. ZIP to TAR goes the other way, producing .tar or .tar.gz with Unix permissions kept and long or non-English names preserved through pax headers. Both run locally in your browser.

The extension alphabet soup

The stacked suffixes describe a pipeline, not one format. archive.tar is an uncompressed bundle. archive.tar.gz means that bundle was passed through gzip, whose container is specified in RFC 1952. archive.gz is the same compressor applied to a single file, with no bundle inside.

ExtensionWhat it actually is
.tarA TAR bundle, no compression
.tar.gz, .tgzTAR bundle compressed with gzip
.tar.bz2, .tbz2TAR bundle compressed with bzip2
.tar.xz, .txzTAR bundle compressed with xz
.tar.zstTAR bundle compressed with Zstandard
.gzOne gzip-compressed file, not a bundle
.zipA ZIP container with its own index, compressed per file

A tool that says it opens .gz may only handle single files. To unpack a bundle you need the TAR layer as well, which is why .tar.gz is often called a tarball.

How extraction works in practice

The structural difference becomes obvious when you want one file out of a large archive. A ZIP reader jumps to the entry using its central directory. A TAR reader must walk the stream from the beginning, skipping headers and data until it reaches the wanted file, because there is no index at the end.

  1. ZIP: read the directory, pick an entry, seek to its offset, decode just that entry.
  2. TAR: read the first header, advance by the stored size, repeat until the target appears.
  3. Compressed TAR: decompress the stream as you go, so a damaged byte early on can affect everything after it.
  4. Before extracting either format, check paths: entries such as ../file or absolute paths must never write outside the chosen folder.

A high compression ratio is a warning sign in either format. A small archive that claims to expand to gigabytes can exhaust memory or disk; Aback ZIP warns before processing such files.

TAR and GZIP support in Aback ZIP

Aback ZIP treats TAR and gzip as separate layers, so it can read compressed tarballs and single compressed files, but it cannot create every codec it can read. The exact division is below; see Create a TAR.GZ file for a worked example of the supported write path.

Input or outputWhat Aback ZIP does
Plain .tarRead, browse and write
.tar.gz and .tgzRead, browse and write
.tar.bz2, .tar.xz, .tar.zst, .tar.lzmaRead and extract
Single .gz fileCompress and decompress
Single .bz2, .xz, .zst or .lzma fileDecompress only
7z and RAR archivesNot supported; detected and reported

Two limits are worth knowing: XZ files that use BCJ filters for executables are not supported, and Zstandard streams that need a dictionary are not supported. Zstandard checksums are not verified. Nothing is uploaded to work around a codec the browser engine cannot handle.

Common tasks, side by side

# Inspect without extracting
unzip -l archive.zip
tar -tf archive.tar.gz

# Extract one named file
unzip archive.zip path/to/file.txt
tar -xzf archive.tar.gz path/to/file.txt

# Create with a chosen level
zip -9 -r archive.zip folder/
tar -cjf archive.tar.bz2 folder/

Note that unzip takes the archive name first and the member path second, while tar -x takes the member after the archive. Both commands extract into the current directory unless you give an output directory, so inspect paths before running them on an unfamiliar file.

Tools for this

Frequently asked questions

Sometimes. gzip compresses the whole stream as one unit, while ZIP compresses each file separately, so for many small, similar files a .tar.gz is often a little smaller. For a few large files the sizes are nearly identical, since both use Deflate.

More guides