About Tar archive files
A tar file bundles files without compressing them, which is why it is usually wrapped in gzip (.tar.gz), bzip2, xz or zstd. Tar has no registered MIME type; application/x-tar is universal.
File signature
TAR files start with "ustar" at byte 257. The extension and the type a browser reports for an upload both
come from the file name, so check these bytes on the server before trusting a file.
Serve .tar with the right Content-Type
Content-Type: application/x-tar
application/x-tar tar;
AddType application/x-tar .tar
@tar path *.tar
header @tar Content-Type "application/x-tar"
curl -sI https://example.com/file.tar | grep -i '^content-type'
# Content-Type: application/x-tar
Set the type in code
res.set('Content-Type', 'application/x-tar');
// Or make the browser download it:
res.attachment('file.tar');
import mimetypes
mimetypes.add_type('application/x-tar', '.tar') # if your system doesn't know it
mimetypes.guess_type('file.tar')[0] # 'application/x-tar'
mime.AddExtensionType(".tar", "application/x-tar")
w.Header().Set("Content-Type", "application/x-tar")
Accept .tar uploads
<input type="file" accept=".tar,application/x-tar">
The accept attribute only filters the file picker; users can still choose another file. Listing the
extension as well as the type matters, because operating systems don’t always report the type you expect.
Related types
-
.gz (
application/gzip): Gzip file -
.zip (
application/zip): ZIP archive -
.7z (
application/x-7z-compressed): 7-Zip archive
More archives
.rar . Look up any extension or type with the MIME type lookup.
Sources
Spotted a mistake? Email hello@devtoolsmith.com and we’ll fix it.
Frequently asked questions
What is the MIME type for .tar files?
application/x-tar. The full header is "Content-Type: application/x-tar".
Why does my server send the wrong Content-Type for .tar?
Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .tar is missing from that table, they send a default such as application/octet-stream or text/plain. Add the mapping as shown on this page, then check the response with "curl -sI".
How can I check that a file really is TAR?
Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. TAR files start with "ustar" at byte 257. The MIME type lookup on this site reads them for you when you drop a file on it.