mime typescontent-typefile typeshttp headersweb development

MIME Types Reference: File Types and Internet Media Types Explained

MIME types identify the format of files and data across HTTP, email, and APIs. Learn how MIME types work, the most important types, and how to set them correctly.

6 min read

Related Tool

MIME Types Reference

Open tool

MIME stands for Multipurpose Internet Mail Extensions. Originally developed for email to support attachments and non-ASCII content, MIME types (also called media types or content types) are now used everywhere: HTTP Content-Type headers, file upload validation, download prompts, API responses, and browser rendering decisions.

Every file transferred over the internet has a MIME type that tells the recipient what kind of data it is and how to handle it. Getting MIME types right matters for correct browser behavior, security, and API compatibility.

The MIME Type Format

A MIME type follows the format type/subtype. The type is a broad category and the subtype is the specific format within that category. An optional parameters section follows a semicolon.

For example: text/html; charset=UTF-8 identifies HTML content encoded in UTF-8. The type is text, the subtype is html, and the parameter specifies the character encoding.

Major MIME Type Categories

text

Text types contain human-readable content. Common examples: text/html for HTML documents, text/plain for plain text, text/css for CSS stylesheets, text/javascript for JavaScript (though application/javascript is also common), and text/csv for CSV data.

The charset parameter is important for text types. UTF-8 is the recommended encoding for web content.

application

Application types represent specific binary or structured formats. Common examples: application/json for JSON data, application/xml for XML, application/pdf for PDF files, application/zip for ZIP archives, application/octet-stream for arbitrary binary data (a common fallback type).

API responses typically use application/json. File downloads where the format is unknown or should be prompted use application/octet-stream.

image

Image types: image/jpeg for JPEG images, image/png for PNG, image/gif for GIF, image/svg+xml for SVG vector graphics, image/webp for WebP, image/avif for AVIF.

Browser-supported image types can be displayed inline. Unsupported types trigger a download.

audio and video

Audio: audio/mpeg for MP3, audio/ogg, audio/wav, audio/webm.

Video: video/mp4, video/webm, video/ogg.

Browser support for audio and video types varies. The HTML audio and video elements use MIME types to determine whether they can play a file.

font

Font types: font/woff, font/woff2, font/ttf, font/otf. Used in CSS font-face declarations and served via HTTP with appropriate headers.

multipart

Multipart types combine multiple parts in one message. multipart/form-data is used for HTML form submissions that include file uploads. multipart/mixed is used in email for messages with attachments.

The Content-Type Header

In HTTP, the Content-Type header carries the MIME type of the request or response body. Servers must set this header correctly so browsers and clients know how to interpret the response.

For JSON APIs: Content-Type: application/json.

For file downloads: Content-Type: application/pdf (or whatever the file type is).

For HTML responses: Content-Type: text/html; charset=UTF-8.

X-Content-Type-Options and MIME Sniffing

Browsers sometimes try to detect the content type by examining the content itself (MIME sniffing), even when the server provides a Content-Type header. This can be a security risk: a server that allows file uploads might be tricked into serving a malicious file with a wrong MIME type that the browser then executes.

Setting the X-Content-Type-Options: nosniff response header tells browsers to honor the declared Content-Type and not sniff.

File Extensions vs MIME Types

File extensions (like .jpg, .pdf, .json) are hints, not guarantees. The MIME type declared in the HTTP Content-Type header is what the browser uses to decide how to handle the response. A file named document.pdf served with Content-Type: text/html would be treated as HTML by the browser.

Using the DevHexLab MIME Types Reference

Open the tool at /tools/reference/mime-types-reference. Browse by category, search by file extension, or look up a MIME type string. Use it to find the correct MIME type to set in your server configuration, API responses, or file handling code.