DevToolsmith

GIF MIME Type

image/gif is the MIME type for GIF images and animations. Here is the Content-Type header to send, the file signature, and how to configure servers and code.

MIME type
image/gif
Extensions
.gif
Content-Type header
image/gif
Registered
Yes, with IANA
Compress with gzip
No, it is already compressed
Category
Images

About GIF image files

Limited to 256 colours per frame, and animated GIFs are huge compared with video. A muted, looping <video autoplay loop muted playsinline> in MP4 or WebM is often many times smaller for the same clip.

File signature

GIF files start with 47 49 46 38 37 61 or 47 49 46 38 39 61 ("GIF87a" / "GIF89a"). 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 .gif with the right Content-Type

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

Set the type in code

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

mimetypes.add_type('image/gif', '.gif')  # if your system doesn't know it
mimetypes.guess_type('file.gif')[0]  # 'image/gif'
Go
mime.AddExtensionType(".gif", "image/gif")
w.Header().Set("Content-Type", "image/gif")

Accept .gif uploads

HTML
<input type="file" accept=".gif,image/gif">

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

  • .webp (image/webp): WebP image
  • .mp4 (video/mp4): MP4 video
  • .png (image/png): PNG image

More images

.jpg , .avif , .heic , .ico , .bmp , .tiff . 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 .gif files?

image/gif. The full header is "Content-Type: image/gif".

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

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

Look at the first bytes rather than the extension or the type the browser reports, which both come from the file name. GIF files start with 47 49 46 38 37 61 or 47 49 46 38 39 61 ("GIF87a" / "GIF89a"). The MIME type lookup on this site reads them for you when you drop a file on it.