The TAR (.tar) Format, Explained
iLoveConverter Team 4 min read
On this page
TAR — Tape ARchive — is a file bundling format, not a compression format. A .tar file concatenates many files and directories into one stream while recording their names, permissions and timestamps. It is the backbone of Unix packaging, and it still looks essentially the same as it did in the 1970s.
One stream, many files
Ancient tape drives could only write sequentially. TAR was designed around that constraint: every file is written as a header block followed by its data, then the next file, until an end marker. There is no central index, so reading a specific file means scanning from the beginning.
Each entry has a 512-byte header containing:
- the path name (up to 100 characters in the original format),
- file mode and permission bits,
- owner and group IDs,
- file size in bytes,
- modification time,
- a type flag (regular file, directory, symlink, hard link, device),
- a checksum for header integrity.
File data follows the header, padded to a multiple of 512 bytes. Directories themselves are stored as entries with a trailing slash; their contents appear as subsequent entries.
Variants that fixed the limits
The original format had tight limits: 100-character names and 8 GB files. Later variants extended it:
| Variant | Adds |
|---|---|
| v7 | The original; very limited |
| ustar | 255-character paths via a prefix field, better metadata |
| GNU tar | Long names, sparse files, incremental backups |
| PAX | Extended headers using key-value records, portable |
PAX is the interoperable modern choice. Most tools write PAX by default or fall back to GNU when needed. Confusingly, the extension stays .tar regardless of variant.
Compression is layered on top
Plain TAR wastes space: a folder of text files stays the same size. Compression is applied as a second step, which is why compound extensions exist:
.tar.gz/.tgz— gzip, fast and universal..tar.bz2/.tbz2— bzip2, better ratio, slower..tar.xz/.txz— xz, best ratio, slowest..tar.zst— zstd, modern speed/ratio balance.
Because the compressor sees the whole TAR stream, it can exploit repetition across files, often beating ZIP’s per-file compression slightly.
What TAR preserves
This is TAR’s main advantage over ZIP on Unix:
- Permission bits — executable flags survive.
- Ownership — useful for system backups, though restoring as another user requires care.
- Symlinks and hard links — stored as links, not duplicated content.
- Timestamps — including modification times.
- Special files — device nodes and FIFOs, relevant for system images.
ZIP can store some of this, but support varies by tool and platform. TAR was built for Unix filesystems and keeps their semantics.
Creating and extracting
tar -cf archive.tar folder/
tar -xf archive.tar
tar -tf archive.tar # list contents
tar -xf archive.tar path/to/file # extract one file
The f flag means “use this file”. Compression flags (z, j, J) combine with creation or extraction. On Windows, 7-Zip opens TAR but cannot preserve Unix ownership or device nodes.
When to use TAR
- Source code distribution — often compressed as
.tar.gz. - System and server backups — preserves permissions and links.
- Streaming pipelines — TAR can be piped directly into a compressor.
- Archival snapshots — plain TAR is simple and stable.
When ZIP is better
If the recipient uses Windows, or you need random access to individual files, ZIP is more practical. Converting TAR to ZIP means extracting the TAR and repacking; contents are unchanged, but Unix metadata may not survive.
Common problems
- “Unexpected EOF” — the archive is truncated, often from an interrupted copy.
- Path traversal — entries like
../../etc/passwdare dangerous; modern extractors reject them. - Garbled filenames — encoding is not standardised; old archives may use local code pages instead of UTF-8.
- Huge archives — TAR has no random access, so extracting one file from a 100 GB archive takes time.
FAQ
Is TAR compressed?
Plain .tar is not compressed at all. .tar.gz, .tar.bz2 and .tar.xz add compression as a second layer.
Can Windows open TAR?
Not natively in older versions. Windows 11 and recent builds add limited TAR support; 7-Zip and WinRAR work reliably.
Does TAR have a size limit?
Classic TAR was limited to 8 GB per file and 100-character names. ustar, GNU and PAX formats remove those limits.
Why use TAR instead of ZIP?
On Unix, TAR preserves permissions, ownership, symlinks and device nodes. ZIP is more convenient for cross-platform sharing.
Try it yourself — free, right in your browser
Everything mentioned in this guide runs locally on this site: no upload, no watermark, no sign-up.
Format deep-dives: TAR (.tar) , TAR.GZ (.tar.gz.tgz) , GZ (.gz)