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

41

2

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.

Lily Finley

Posted 2015-04-15T16:30:56.780

Reputation: 640

Perhaps this question will be useful to you: http://stackoverflow.com/questions/23600229/what-content-type-header-to-use-when-serving-gzipped-files

– Nick2253 – 2015-04-15T16:36:18.083

Answers

66

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).

Suncat2000

Posted 2015-04-15T16:30:56.780

Reputation: 801

"application/zip" worked for me. I always thought tar.gz was just a zipped tarball. – PJ Brunet – 2017-02-19T22:21:02.783

3@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 – 2017-03-07T16:58:14.133

1If 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 – 2018-07-09T12:56:59.900

4

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.

td512

Posted 2015-04-15T16:30:56.780

Reputation: 4 778

1When I rewrote the file with application/x-gzip, It got corrupted. But when I used application/gzip, it worked. – Amit Kumar Gupta – 2016-12-04T16:15:10.893

14cPanel isn't a standard of anything except bad coding practices. – Lizardx – 2017-08-17T19:12:21.383

hahaha. ooouch ! – Kennet Celeste – 2019-11-21T13:10:37.870