MIME Types Cheat Sheet
Common MIME types, Content-Type headers, multipart forms, and how to detect and set them correctly.
Web & Network
mime
content-type
http
MIME types (media types) tell the browser and servers how to interpret a resource. The Content-Type header declares the type and, optionally, a charset or boundary.
Common MIME types
Table
| Type | Extension |
|---|---|
text/html | .html |
text/css | .css |
text/plain | .txt |
application/json | .json |
application/javascript | .js |
application/xml | .xml |
image/png | .png |
image/jpeg | .jpg |
image/svg+xml | .svg |
image/webp | .webp |
application/pdf | |
application/zip | .zip |
application/octet-stream | (binary fallback) |
multipart/form-data | (file uploads) |
Content-Type header
code
Content-Type: text/html; charset=utf-8
Content-Type: application/json
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary
Table
| Component | Meaning |
|---|---|
type/subtype | The media type. |
charset | Character encoding (text types). |
boundary | Separator for multipart bodies. |
Multipart form data
code
------WebKitFormBoundary
Content-Disposition: form-data; name="file"; filename="a.png"
Content-Type: image/png
<binary data>
------WebKitFormBoundary--
Detection
Table
| Method | Notes |
|---|---|
| File extension | Simple but spoofable. |
| Magic bytes | Inspect file signature (e.g. %PDF, \x89PNG). |
Server Content-Type | Trust but verify for uploads. |