Files and data
What is MIME type?
Short for Multipurpose Internet Mail Extensions type. Also called media type or content type.
A MIME type is a label such as image/png or application/pdf that tells browsers, email programs and servers what kind of data a file contains.
How it works
MIME types were created so email could carry attachments, and the web adopted them to describe everything a server sends. Each has a type and a subtype separated by a slash: image/jpeg, text/html, application/pdf.
A server includes the MIME type in a Content-Type header. The browser uses it to decide whether to render the data, play it, open a viewer or offer a download. Data URLs start with a MIME type for the same reason.
MIME type vs extension
On your computer, the extension tells the operating system what a file is. When the file travels over the internet, the MIME type does that job. Browsers usually derive the MIME type from the extension when you upload something, so a wrong extension becomes a wrong MIME type, which is why checking a file’s actual signature is more reliable than trusting either label.
A practical example
When a website sends a PDF with the MIME type application/pdf, the browser opens its built-in viewer. Sent as application/octet-stream, the same file is simply downloaded.
What to watch out for
An upload form may check the MIME type your browser reports, which usually comes from the file extension. A renamed file can pass that check and still fail when the site processes it.
Tools you can use
- File Type Checker · What a file really is, whatever it is called
- Image to Base64 · Embed an image directly in your code
Go a little deeper
- How to embed an image in HTML or CSS with Base64
- Renamed a file and now it’ll not open?
- What is a file extension?
- Why won’t a website accept my photo?
Common questions
What MIME type is a JPG?
image/jpeg. Other common ones are image/png, image/webp, image/svg+xml, application/pdf, text/csv, application/json and application/zip.
Why does a website reject my file even though it has the right extension?
The site may check the file’s real contents as well as its name. A HEIC or WebP photo renamed to .jpg still contains HEIC or WebP data, so the check fails.
Where are MIME types used?
In web server responses, email attachments, file upload forms and data URLs. They let the receiving program decide how to handle data without guessing from a filename.