What is a TAR file?
A TAR file is a bundle of files and folders written one after another into a single file, each behind a header recording its name, size, permissions, owner and modification time. The name is short for tape archive: tar first shipped with Version 7 Unix in 1979, to write file trees to magnetic tape.
Tar does not compress. A .tar is roughly the size of everything in it, plus headers and padding. Compression is a separate layer applied to the whole tar afterwards — which is what a .tar.gz (or .tgz) is: a tar file, gzipped.
Do it in your browser, nothing uploaded
- Open a TAR fileOpen and extract .tar archives in your browser: v7, USTAR, PAX and GNU long names. See every entry, then download all of it or one file. Nothing is uploaded.
- Extract a TAR.GZ fileOpen and extract .tar.gz and .tgz files in your browser. See every file inside, then download all of it or just what you need. Nothing is uploaded.
- Convert TAR to ZIPTurn a .tar into a .zip in your browser. Entries are read from the tar stream and compressed into a new ZIP; nothing is uploaded.
- Open a GZ fileDecompress .gz files in your browser — .sql.gz, .log.gz, .json.gz, .csv.gz and multi-member gzip. A .tar.gz inside is unpacked too. Nothing is uploaded.
Inside a tar: 512-byte blocks
A tar is a sequence of 512-byte blocks. Each entry is one header block followed by its data, padded with zeros to the next 512-byte boundary, and the archive ends with two blocks of zeros. Numbers in the header are written as ASCII octal. There is no index: to list a tar, a reader walks from header to header, using each size field to skip the data in between.
| Offset | Bytes | Field |
|---|---|---|
| 0 | 100 | File name |
| 100 | 8 | Mode (permission bits, octal) |
| 108 / 116 | 8 + 8 | Owner and group IDs |
| 124 | 12 | Size in bytes (octal) |
| 136 | 12 | Modification time, seconds since 1970 (octal) |
| 148 | 8 | Header checksum |
| 156 | 1 | Type: 0 file, 1 hard link, 2 symlink, 3/4 device, 5 directory, 6 FIFO |
| 157 | 100 | Link target |
| 257 | 6 | Magic: ustar |
| 265 / 297 | 32 + 32 | Owner and group names |
| 345 | 155 | Path prefix, so USTAR paths can reach 255 bytes |
Because the first bytes of a tar are just a file name, tar has no signature at offset zero. It is recognised by the ustar magic at byte 257 (75 73 74 61 72) or, for the original v7 layout that predates it, by a header whose checksum adds up. That is exactly how this site detects one.
Four dialects
- v7 — the original: 100-byte names, no magic, no owner names.
- USTAR (POSIX.1-1988) — adds the
ustarmagic, owner and group names, and the 155-byte prefix field. - GNU — adds
LandKpseudo-entries carrying names and link targets of any length, and sparse files. - PAX (POSIX.1-2001) — adds
xandgextended headers ofkey=valuerecords in UTF-8: unlimited path length, sizes beyond 8 GiB, sub-second timestamps. Modern GNU tar and bsdtar write PAX when a plain USTAR header cannot hold the entry.
The reader on this site handles all four, plus base-256 numeric fields. When it writes a tar it emits USTAR and adds a PAX header only for an entry that needs one — a path that is too long or not plain ASCII.
What is a .tar.gz or .tgz file?
A tar compressed as a single stream. .tgz is the same thing under a three-letter extension. Because the compressor sees the whole archive at once it can exploit repetition across files, so a .tar.gz of many small, similar files can be smaller than a ZIP of the same files. The cost is that there is no random access: to list or extract anything, everything before it has to be decompressed first.
| Extension | Compression | Magic bytes | tar flag | Read here |
|---|---|---|---|---|
| .tar.gz, .tgz | gzip (DEFLATE) | 1F 8B | -z | Yes |
| .tar.bz2, .tbz2 | bzip2 | 42 5A 68 | -j | No — recognised and refused |
| .tar.xz, .txz | xz (LZMA2) | FD 37 7A 58 5A 00 | -J | No — recognised and refused |
| .tar.zst | Zstandard | 28 B5 2F FD | --zstd | No — recognised and refused |
How to extract a tar to a directory
On Linux and macOS, and on Windows 10 version 1803 or later (which ships tar.exe, a build of bsdtar), the same commands work. -C changes into the target directory before extracting; with GNU tar the directory must already exist.
tar -tf archive.tar # list the contents
tar -xf archive.tar # extract into the current folder
mkdir -p out && tar -xf archive.tar -C out # extract into out/
tar -xzf archive.tar.gz -C out # gzip-compressed (.tar.gz, .tgz)
tar -xf archive.tar -C out --strip-components=1 # drop the top folder
tar -xf archive.tar path/in/archive.txt # extract one fileBoth GNU tar and bsdtar detect gzip, bzip2 and xz by themselves when extracting from a file, so tar -xf alone can work for compressed tars too. Windows 11 version 23H2 added archive reading to File Explorer (Microsoft's release notes), built on the open-source libarchive library — the same library this site runs as WebAssembly for RAR and 7z. Windows 10 and earlier need a separate program.
Permissions, links and safety
Tar records what Unix needs to restore a file tree faithfully: permission bits including setuid, owner and group, symbolic links, hard links, device nodes and FIFOs. That is why it remains the format for backups, source releases and container images.
It also means a tar can carry hostile entries: an absolute path such as /etc/cron.d/job, a ../ path that climbs out of the target folder, or a symlink that later entries are written through. GNU tar strips leading slashes from member names and skips members whose path contains .., unless told otherwise. Python's tarfile did neither for well over a decade (CVE-2007-4559); Python 3.12 added extraction filters, and filter="data" is the default from 3.14.
Here, every path is checked before anything is written and unsafe ones are blocked and named. Symbolic links are listed but never written, a hard link to an earlier file is written as a copy of it, and device nodes, FIFOs and GNU sparse files are listed with the reason they are not written.
Tar has no encryption and no password. To protect a tarball, encrypt the whole file with a tool such as GnuPG or age, or use a format that encrypts — ZIP with AES, or 7z.
Questions
What is the difference between .tar and .tar.gz?
A .tar is the uncompressed bundle; a .tar.gz is that bundle compressed with gzip. Extracting a .tar.gz undoes the gzip first and then reads the tar — tar -xzf does both in one step, and so do the TAR.GZ tools here.
Is a .tgz file the same as a .tar.gz?
Yes, byte for byte. .tgz is the short form from systems that limited extensions to three characters. Detection here is by content, so either name works, and so does a mis-named file.
How do I extract a tar file to a specific directory?
tar -xf archive.tar -C /path/to/dir. The directory must exist for GNU tar, so create it first with mkdir -p /path/to/dir. Add --strip-components=1 to drop the archive's top-level folder.
Can Windows open a tar file?
Windows 11 version 23H2 and later opens .tar and .tar.gz in File Explorer. Windows 10 from version 1803 has tar.exe in Command Prompt and PowerShell. On anything else — or a locked-down work machine — the TAR opener here works in the browser.
Why is my .tar bigger than the files in it?
Tar does not compress, and every entry costs a 512-byte header plus padding to the next 512-byte boundary. Many tiny files make that overhead noticeable. Compress the tar (tar -czf) or convert it to a ZIP if size matters.
Can a tar file be password protected?
No — the format has no encryption. Encrypt the finished .tar or .tar.gz as a whole file, or use ZIP with AES or 7z if the archive itself must carry a password.