71

What is the correct MIME type for a tar.gz file?

I've searched around and found several values being used, including:

application/x-gzip
application/x-gtar
application/x-tgz

But I could find no indication as to which of these (if any) was the correct or canonical value.

1

2 Answers 2

107

As of August 2012, the MIME type recommended in RFC 6713 is application/gzip.

According to the IANA registry, tar is not an official media type, so a GZipped tar file is officially only a compressed file.

Hypothetically, if a tarball were an official media type and following conventions, its MIME type would be application/tar (file extension .tar) and its compressed version would be application/tar+gzip (file extensions .tar.gz and .tgz).

4
  • "application/zip" worked for me. I always thought tar.gz was just a zipped tarball.
    – PJ Brunet
    Feb 19, 2017 at 22:21
  • 5
    @PJBrunet That would be an incorrect media type because application/zip is a different format than application/gzip and tar.gz is a gzipped tarball; Zip uses multiple compression methods, not all of which are freely licensed. Perhaps you got lucky and your decompression library recognizes both formats from their data stream.
    – Suncat2000
    Mar 7, 2017 at 16:58
  • 3
    If tar is not an official media type, would that not make application/x-tar+gzip the most correct? I feel that would be more clear even if it's less... official.
    – Will S
    Jul 9, 2018 at 12:56
  • Ubuntu labels XZ compressed tar as application/x-xz-compressed-tar. But that's not super useful as the Nautilus file picker doesn't obey non-standard mime types... the ones with "x-". In practice for HTML forms, you'd use extensions in the accept field for non standard types.
    – Ray Foss
    Oct 13, 2021 at 14:55
6

Although most are deprecated, they are all technically correct, just different MIME types.

The correct MIME type is application/x-gzip according to cPanel standards.

3
  • 1
    When I rewrote the file with application/x-gzip, It got corrupted. But when I used application/gzip , it worked. Dec 4, 2016 at 16:15
  • 26
    cPanel isn't a standard of anything except bad coding practices.
    – Lizardx
    Aug 17, 2017 at 19:12
  • Same experience as Amit:application/x-gzip and application/tar+gzip produced corrupted files, whereas application/gzip worked.
    – ctenar
    Feb 19, 2021 at 7:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .