A MIME (Multipurpose Internet Mail Extensions) type, also known as a media type, is a label used to identify and classify different types of data on the Internet.
MIME types play a crucial role in web communication by specifying the nature and format of a file or stream of data. They are used in headers of HTTP requests and responses, email systems, and other contexts where it’s important to convey information about the content being transmitted.
MIME Type Elements
A MIME type consists of two parts:
- Top-Level Type (or Primary Content Type)
- Subtype
Top-Level Type (or Primary Content Type)
This indicates the general category of the data. Common top-level types include:
Common top-level types include:
text | Textual information |
image | Image data |
audio | Audio data |
video | Video data |
application | Binary data or data to be processed by an application |
multipart | A container for multiple parts, often used for email attachments |
Subtype
This further refines the definition of the data type within the top-level type.
Here are some examples:
text/plain | Plain text. |
image/jpeg | JPEG image |
audio/mp3 | MP3 audio |
video/mp4 | MP4 video |
application/pdf | PDF document |
multipart/form-data | Form data used in HTTP requests |
MIME types are standardized and registered with the Internet Assigned Numbers Authority (IANA) to ensure consistency and interoperability. When a server sends a file to a browser, it includes the appropriate MIME type in the Content-Type
header of the HTTP response. This header helps the browser interpret and handle the content correctly.
How MIME Types Works
For example, a server might send the following Content-Type
header for a JPEG image:
Content-Type: image/jpeg
This informs the browser that the content is in JPEG format, allowing the browser to render it appropriately.
In addition to serving content over the web, MIME types are used in email systems to specify the type of attachments, allowing email clients to handle attachments appropriately based on their types.