A MIME type is a standardized two-part identifier, written as type/subtype (for example image/png or application/json), that declares what kind of data a file, message body or network response contains. The label is also called a media type or content type, and it is a cornerstone of interoperability in software because it lets a sender and a receiver agree on how bytes should be interpreted without relying on file names.
The concept originated in the Multipurpose Internet Mail Extensions specifications for email and was later adopted by HTTP, web browsers, operating systems and APIs. Today the official list of media types is maintained by the IANA media type registry, and the syntax is defined in RFC 6838 and related specifications.
How a MIME type is structured
Every MIME type consists of a top-level type, a slash and a subtype, optionally followed by parameters separated by semicolons. The top-level type names a broad category, while the subtype names the specific format. A parameter refines the meaning, most commonly charset for text, as in text/plain; charset=utf-8.
Matching is case-insensitive for the type and subtype, so Text/HTML and text/html are equivalent, although lowercase is the convention. Subtypes may also carry a structured syntax suffix such as +json or +xml, which tells a generic parser that, for example, application/ld+json can be read as ordinary JSON even when the specific vocabulary is unknown.
The following table lists the registered top-level types and what each one covers.
| Top-level type | What it covers | Typical subtypes |
|---|---|---|
| text | Human-readable character data | plain, html, css, csv |
| image | Still or animated pictures | png, jpeg, webp, svg+xml |
| audio | Sound data | mpeg, ogg, wav |
| video | Moving images, often with sound | mp4, webm |
| application | Binary data or data for a program | json, pdf, zip, octet-stream |
| font | Font files | woff2, ttf, otf |
| multipart | Several parts in one body | form-data, mixed, alternative |
| model | Three-dimensional models | gltf+json, obj |
Where MIME types are declared and read
A MIME type travels as metadata alongside the data, not inside it. In HTTP, the server sends it in the Content-Type header, and the client may state the types it prefers in the Accept header, which enables content negotiation. In email, each part of a multipart message carries its own Content-Type, so a single message can hold text, HTML and attachments.
Operating systems use MIME types as well. Desktop environments map file extensions and magic numbers (signature bytes at the start of a file) to media types and then to the application that opens them. Upload forms send multipart/form-data, and the HTML accept attribute filters which files a user may select.
The table below summarizes the main places where the label appears and who relies on it.
| Context | Field or mechanism | Consumer |
|---|---|---|
| HTTP response | Content-Type header | Browser, API client |
| HTTP request | Accept and Content-Type headers | Server, API gateway |
| Email message | Content-Type per MIME part | Mail client |
| File manager | Extension and magic-number database | Operating system shell |
| Web page markup | type and accept attributes | Browser |
| Archive manifest | Declared entries such as EPUB mimetype | Reader application |
MIME types compared with extensions and content sniffing
A MIME type is an explicit declaration, whereas a file extension is only a naming convention and content sniffing is an inference from the bytes. Each method fails in different ways, so robust software usually combines them and treats the declared type as authoritative only when the source is trusted.
| Method | Strength | Weakness |
|---|---|---|
| Declared MIME type | Explicit, works without a file name | Can be missing or misconfigured |
| File extension | Simple and visible to users | Easily renamed, varies by platform |
| Content sniffing | Inspects actual bytes | Ambiguous formats, security risks |
The distinction matters for neighboring concepts such as file format and character encoding. A MIME type names the container or syntax, while the charset parameter names the character encoding, so a correct type with a wrong charset still produces mojibake.
Choosing and configuring the right media type
The most specific registered type is the correct choice whenever one exists. Generic labels force receivers to guess, and guessing undermines both reliability and security. When no registered type fits, vendors may use the vnd. tree for proprietary formats or the x- prefix, which RFC 6838 now discourages for new types.
| Payload | Recommended type | Reason |
|---|---|---|
| JSON API response | application/json | Registered, UTF-8 by definition |
| Web page | text/html; charset=utf-8 | Explicit encoding avoids misreading |
| JavaScript file | text/javascript | Current registered form |
| Unknown binary download | application/octet-stream | Signals raw bytes, triggers download |
| Scalable vector graphic | image/svg+xml | Suffix exposes XML syntax |
| Office document | Registered vnd. type | Lets systems pick the right editor |
Web servers assign types through a mapping file or configuration directive, and object storage services usually set them at upload time. A useful practice is to verify response headers after every deployment, because a missing mapping silently falls back to a generic default.
Common mistakes and security pitfalls
Incorrect media types cause both functional failures and vulnerabilities. Browsers historically sniffed content to compensate for misconfigured servers, which allowed attackers to upload a file that looked harmless but was executed as script. The X-Content-Type-Options: nosniff header tells the browser to trust the declared type and refuse mismatched scripts and stylesheets.
- Serving everything as text/plain breaks rendering of pages, stylesheets and scripts.
- Trusting the uploaded Content-Type lets a client mislabel malicious files; validate on the server.
- Omitting the charset parameter for text invites wrong decoding of non-ASCII characters.
- Inventing unregistered types reduces interoperability with tools that rely on the registry.
- Using application/octet-stream everywhere forces downloads where inline display was intended.
The short version
A MIME type is a label that says what is inside a piece of data. Think of a parcel with a sticker that reads “fragile glass” or “frozen food”. The sticker does not change the contents, but it tells the person receiving it how to handle the box.
When a website sends a picture, it attaches the label image/png, so the browser knows to draw an image instead of showing strange symbols. Without the right label, programs have to guess, and guesses are sometimes wrong or even unsafe.
Where it makes a difference
A development team moves a single-page web application from one hosting setup to a new storage bucket behind a content delivery network. After the switch, the page loads as a blank screen. The browser console reports that the main script was refused because its MIME type was text/plain and the server sends nosniff.
The cause is that the upload tool did not map the .js and .mjs extensions, so every file received a generic default. The team adds explicit mappings for text/javascript, text/css, image/svg+xml and application/wasm, re-uploads the assets and adds a deployment check that requests each file type and compares the Content-Type header with the expected value. The application renders correctly again, and future releases fail the pipeline instead of failing in front of users.