The Label on the Bytes
A MIME type — also called a media type or content type — is how the web identifies what a piece of data is. The server declares it in the Content-Type header of its response:
Content-Type: text/html; charset=utf-8
That single line is the browser's instruction. Without it, the browser would be guessing at a stream of bytes; with it, the browser knows to parse the body as HTML and decode the text as UTF-8. Every resource that crosses the web — the page, each image, the stylesheet, the fonts, the data an API returns — arrives stamped with one of these labels. The name is a historical accident: MIME stands for Multipurpose Internet Mail Extensions, invented so email could carry attachments and images rather than only plain text. The web borrowed the same scheme, and the name stuck.
How a MIME Type Is Built
Every MIME type follows the same shape: a type, a slash, and a subtype, with an optional parameter after a semicolon.
type/subtype; parameter
text/html; charset=utf-8
│ │ │
broad specific extra detail
category format (here, the character set)
The type is one of a small set of broad categories — text, image, audio, video, application, font, and a couple of multipart types. The subtype pins down the exact format within that category. So image/png and image/jpeg are both images but different formats, while application/json and application/pdf are both "application data" of very different kinds. The catch-all application/octet-stream means "arbitrary binary data" — effectively "I don't know what this is, treat it as a download."
The Ones You Will Actually See
| MIME type | What it is |
|---|---|
text/html | A web page |
text/css | A stylesheet |
text/javascript | A JavaScript file |
application/json | JSON data — the lingua franca of web APIs |
image/png, image/jpeg, image/webp | Common image formats |
image/svg+xml | A vector image (note the +xml structured-syntax suffix) |
application/pdf | A PDF document |
application/octet-stream | Generic binary — usually triggers a download |
multipart/form-data | A form submission that includes file uploads |
The Accept request header is the mirror image of all this: it is how the browser tells the server which MIME types it would like in return. An API client might send Accept: application/json to ask for data rather than a web page — a small negotiation that lets one URL serve different formats to different callers.
MIME Type vs File Extension
It is tempting to think a file named report.pdf is "a PDF because of the .pdf," but on the web that is not how it works. The extension is part of the filename and is, at best, a hint. The authority is the Content-Type header the server sends. Browsers obey the header and largely ignore the extension — so a genuine PDF served with Content-Type: text/plain will be shown as gibberish text, and a file called photo.png served as text/html will be parsed as a web page. The label travels with the response; the name travels with the file, and only the label is binding.
This is exactly why the classic "my browser is showing code instead of the page" problem happens. The server sent the HTML with the wrong content type — often text/plain — so the browser faithfully displayed the source rather than rendering it. The page is fine; the label is wrong. Fixing it is a server configuration change, not an edit to the page itself.
MIME Sniffing and Why It Is Restrained
Browsers historically tried to be helpful when a content type looked wrong or missing: they would peek at the actual bytes and guess the real type, a behaviour called MIME sniffing. Convenient, but a security hazard — a file a server believed was harmless text could be sniffed and executed as a script, opening the door to attacks. The response is the X-Content-Type-Options: nosniff header, which tells the browser to trust the declared type and never second-guess it. Most security-conscious sites send it, and it is a small reminder of the larger principle: the MIME type is a declaration of intent, and the safest systems are the ones that take that declaration at its word. To see where the Content-Type header sits among the others, the HTTP headers guide lays out the full set, and how HTTP works shows the response it rides in.
Frequently Asked Questions
What is a MIME type?
A short label that tells software what kind of data a file contains — text/html for a web page, image/png for an image, application/json for API data. On the web the server sends it in the Content-Type header so the browser knows how to handle the bytes.
How is a MIME type structured?
Two parts separated by a slash: a type and a subtype, like text/html or image/png. The type is the broad category and the subtype the specific format. An optional parameter can follow a semicolon, most often a character set, as in text/html; charset=utf-8.
What is the difference between a MIME type and a file extension?
An extension like .png is part of the filename and only a hint. The MIME type is the authoritative declaration the server sends in the Content-Type header. Browsers trust the header, not the extension — so a file's name does not decide how it is treated.
Why is my browser showing code instead of a web page?
The server most likely sent the wrong MIME type — text/plain instead of text/html. Because the browser obeys the Content-Type header, it shows the raw source rather than rendering it. The fix is to configure the server to return the correct type.
What does MIME stand for?
Multipurpose Internet Mail Extensions. It was created so email could carry more than plain text — images and attachments. The web adopted the same labelling system, which is why these labels are also called media types or content types.