DevToolsmith

GZ MIME Type

application/gzip is the MIME type for gzip-compressed files (.gz, .tar.gz). Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
application/gzip
Extensions
.gz, .tgz
Content-Type header
application/gzip
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Archives

About Gzip file files

Registered in RFC 6713; application/x-gzip is the older name. Don’t confuse the content type with Content-Encoding: gzip: if a server sends a .tar.gz download with Content-Encoding: gzip, the browser decompresses it on the fly and saves a plain .tar under a .tar.gz name.

Other types seen for these files: application/x-gzip . Accept them when reading uploads, but send application/gzip yourself.

File signature

GZ files start with 1F 8B. 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 .gz with the right Content-Type

Response header
Content-Type: application/gzip
nginx (a line in the types { } block of mime.types)
application/gzip gz tgz;
Apache (.htaccess or server config)
AddType application/gzip .gz .tgz
Caddy
@gz path *.gz *.tgz
header @gz Content-Type "application/gzip"
Check what a server sends
curl -sI https://example.com/file.gz | grep -i '^content-type'
# Content-Type: application/gzip

Set the type in code

Node.js (Express)
res.set('Content-Type', 'application/gzip');
// Or make the browser download it:
res.attachment('file.gz');
Python
import mimetypes

mimetypes.add_type('application/gzip', '.gz')  # if your system doesn't know it
mimetypes.guess_type('file.tar.gz')  # ('application/x-tar', 'gzip')
Go
mime.AddExtensionType(".gz", "application/gzip")
w.Header().Set("Content-Type", "application/gzip")

Accept .gz uploads

HTML
<input type="file" accept=".gz,.tgz,application/gzip">

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

  • .tar (application/x-tar): Tar archive
  • .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 .gz files?

application/gzip. You may also see application/x-gzip, which is older or unofficial; send application/gzip. The full header is "Content-Type: application/gzip".

Why does my server send the wrong Content-Type for .gz?

Web servers pick the type from the file extension using a table (mime.types in nginx and Apache). If .gz 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 GZ?

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. GZ files start with 1F 8B. The MIME type lookup on this site reads them for you when you drop a file on it.