A MIME type (or media type) names the format of a piece of content in the form type/subtype, such as image/png. Web servers send it in the Content-Type header so the browser knows whether to render a page, play a video or offer a download. Look up any extension with the MIME Type Lookup.
Common types
| Type | Extensions | Used for |
|---|---|---|
text/html |
.html .htm |
Web pages |
text/css |
.css |
Stylesheets |
text/javascript |
.js .mjs |
JavaScript (the current standard type) |
application/json |
.json |
JSON data and API responses |
application/xml |
.xml |
XML documents |
text/plain |
.txt |
Plain text |
text/csv |
.csv |
Comma-separated tables |
text/markdown |
.md |
Markdown text |
application/pdf |
.pdf |
PDF documents |
application/zip |
.zip |
ZIP archives |
application/gzip |
.gz |
Gzip-compressed data |
application/wasm |
.wasm |
WebAssembly modules (must be served with this type to stream-compile) |
image/png |
.png |
PNG images |
image/jpeg |
.jpg .jpeg |
JPEG photos |
image/gif |
.gif |
GIF images and animations |
image/webp |
.webp |
WebP images |
image/svg+xml |
.svg |
SVG vector graphics |
audio/mpeg |
.mp3 |
MP3 audio |
audio/wav |
.wav |
WAV audio |
video/mp4 |
.mp4 |
MP4 video |
video/webm |
.webm |
WebM video |
font/woff2 |
.woff2 |
Web fonts (WOFF2) |
Rules worth remembering
- Unknown binary data is
application/octet-stream. Browsers usually offer to download it instead of opening it. - Form submissions use
application/x-www-form-urlencodedby default andmultipart/form-datawhen a file is attached. - Text types often carry a charset, as in
text/html; charset=utf-8. Always send UTF-8 for text (UTF-8). - Structured types end in
+jsonor+xmlwhen they are specialised versions of those formats, such asimage/svg+xmlorapplication/ld+json. - Vendor and experimental types start with
vnd.(for exampleapplication/vnd.ms-excel) orx-.
Common problems
- A page shows as plain text. The server sent
text/plaininstead oftext/html. - A script or module will not run. Browsers refuse JavaScript modules and strict-MIME scripts served with a wrong type such as
text/htmlorapplication/octet-stream. - A font or WebAssembly file fails to load. Servers that do not know
.woff2or.wasmmay send a generic type. - Type sniffing. Browsers sometimes guess a type from the content. Send
X-Content-Type-Options: nosniffso they trust yourContent-Typeinstead.
Checking uploads
Never trust an uploaded file's extension or the Content-Type the client sent: both are chosen by the sender. Check the file's first bytes against its expected signature instead (see How File Signatures (Magic Bytes) Work), and serve uploads from a separate domain with nosniff.