A TAR file is an archive produced using the TAR format, whose name derives from "tape archive". TAR was originally designed to store multiple files and directory structures sequentially in a single archive stream, particularly for use with magnetic tape and Unix backup workflows. Unlike ZIP, TAR is fundamentally an archive or packaging format rather than a compression algorithm.
A tar archive can contain many files, directories, symbolic links and other filesystem objects, represented sequentially along with metadata such as names, sizes, permissions and timestamps. A TAR archive traditionally uses the .tar extension. Because the format is a container rather than a compression method, a plain .tar file may be considerably larger than the combined compressed contents of its members. Compression is commonly added as a separate processing layer.
TAR's historical design is based on writing archive records sequentially. Each archived filesystem object is represented by a header containing metadata followed by its associated data, with padding used to maintain the format's block-oriented structure. Directories can be represented so that extraction software can recreate the corresponding hierarchy, while symbolic links can be stored as links rather than merely copying the target's contents.
The sequential structure is well suited to streams, pipes, tapes and other media where data naturally moves from beginning to end. It also explains why TAR differs from archive formats that maintain a central index optimised for direct access to individual members. Tools can list or extract selected entries, but accessing an individual file may involve processing preceding archive structure depending on the implementation and available indexing mechanisms.
TAR preserves significant filesystem metadata, although the precise information depends on the tar format variant and implementation. Traditional tar headers provide fields for filenames, file modes, ownership identifiers, file sizes and timestamps, while later extensions support longer names, extended attributes, ACLs and other metadata. GNU tar, POSIX tar and other implementations can differ in supported extensions and behaviour.
This is important when transferring archives between Unix-like systems or preserving system backups because permissions, ownership, symbolic links and special files may be semantically important. A tar archive therefore represents more than the raw contents of ordinary documents; it can encode aspects of the filesystem namespace and metadata necessary to reconstruct a directory hierarchy.
TAR itself does not generally compress the files it stores. Instead, a tar archive can be passed through a separate compressor. This produces familiar combinations such as .tar.gz, .tgz, .tar.bz2, .tar.xz and .tar.zst, where tar performs the packaging and gzip, bzip2, xz or Zstandard performs compression. The distinction can be expressed conceptually as "archive first, compress second". A tar stream containing thousands of files becomes one sequential stream that can then be compressed as a whole. Compressing the combined stream can exploit redundancy across file boundaries and metadata, while individual-file compression in formats such as ZIP can provide more convenient independent extraction. The choice affects compression efficiency, access characteristics and tooling.
The combination of TAR with compression became especially important in Unix and Linux software distribution. Source-code projects, package source archives, backups and collections of configuration files have commonly been distributed as tarballs, a term traditionally referring to a tar archive, often compressed. A filename such as project.tar.gz therefore does not mean that gzip itself understands thousands of files; gzip compresses the tar stream, while tar defines how the files are packaged. To extract the contents, software normally decompresses the gzip layer and then interprets the resulting tar archive. Modern tools can combine these stages transparently, which can make the underlying two-layer structure less obvious to users.
TAR differs from ZIP in several practical respects. ZIP normally stores each entry as a separately represented member and commonly compresses each member independently, with a central directory facilitating archive navigation. TAR stores members sequentially and traditionally leaves compression to an external algorithm. TAR is particularly strong for preserving Unix-style filesystem structures and metadata, whereas ZIP is often favoured for broad end-user portability and convenient graphical extraction.
Neither format is inherently universally superior because the appropriate choice depends on requirements such as metadata fidelity, cross-platform compatibility, streaming, random access, compression behaviour and available software. TAR's stream-oriented design is particularly useful in Unix pipelines, where archive output can be sent directly into another program without first creating a temporary archive file.
TAR archives also require careful handling when extracting untrusted data. Archive entries contain filenames and paths, and a malicious archive can attempt to use paths containing parent-directory components or absolute paths to write files outside the intended extraction directory. Symbolic links can create additional complications if an extractor follows links in unsafe ways. Secure extraction software should validate entry paths, handle links safely and apply appropriate permissions rather than blindly recreating every archive member. TAR itself is not malicious or insecure; these risks arise because archive formats encode filesystem paths and extraction is an operation that creates filesystem objects. Similar path traversal risks exist in ZIP and other archive formats.
TAR remains an important technical format because its simple sequential archive model integrates naturally with Unix-like command-line tooling, backup workflows, build systems and compression utilities. Its name reflects its original tape-oriented purpose, but modern tar archives are more commonly stored on disks, SSDs, network systems and cloud storage than on magnetic tape.
A .tar file is an archive, not necessarily a compressed file; a .tar.gz file is a tar archive compressed using gzip; and a .tar.xz file is a tar archive compressed using xz. Recognising this layered structure is essential when explaining Unix archives accurately. TAR's continued use demonstrates the longevity of a simple, stream-friendly container format that can package large collections of filesystem objects while preserving important metadata.