What is MIME Type?
MIME Type is a standardized identifier used to indicate the nature and format of a file or data, consisting of a type and subtype separated by a slash, enabling proper handling of content across the internet.
Quick Facts
| Full Name | Multipurpose Internet Mail Extensions Type |
|---|---|
| Created | 1992 (RFC 1341, RFC 1521) |
| Specification | Official Specification |
How It Works
MIME types, originally developed for email attachments, have become the standard way to identify content types on the web. Each MIME type consists of a type (e.g., text, image, application) and a subtype (e.g., html, png, json), optionally followed by parameters. Web servers send MIME types in Content-Type headers to tell browsers how to handle responses. Common examples include 'text/html' for web pages, 'application/json' for JSON data, and 'image/png' for PNG images. The Internet Assigned Numbers Authority (IANA) maintains the official registry of MIME types.
Key Characteristics
- Format: type/subtype (e.g., text/plain, image/jpeg)
- Optional parameters (e.g., text/html; charset=utf-8)
- Registered types: text, image, audio, video, application, multipart, message
- Vendor-specific types use 'vnd.' prefix
- Unregistered types use 'x-' prefix (deprecated)
- Case-insensitive by specification
- Critical for proper content handling
Common Use Cases
- HTTP Content-Type headers
- File upload validation
- Email attachment handling
- API response formatting
- Browser content rendering decisions
Example
Loading code...Frequently Asked Questions
What happens if a server sends the wrong MIME type?
If a server sends an incorrect MIME type, browsers may mishandle the content. For example, sending JavaScript with 'text/plain' instead of 'application/javascript' may prevent script execution. Sending HTML as 'application/octet-stream' will trigger a download instead of rendering the page.
What is the difference between MIME type and file extension?
File extensions (like .jpg, .html) are part of the filename and used by operating systems to associate files with applications. MIME types are standardized identifiers sent in HTTP headers that tell browsers how to handle content. While often related, they serve different purposes - MIME types are authoritative for web content handling.
How do I find the correct MIME type for a file?
You can look up MIME types in the IANA Media Types registry (iana.org/assignments/media-types). Common types include 'text/html' for HTML, 'application/json' for JSON, 'image/png' for PNG images, and 'application/pdf' for PDF documents. Most web frameworks and servers can auto-detect MIME types.
What does 'application/octet-stream' mean?
application/octet-stream is the default MIME type for binary files when the actual type is unknown. It tells the browser to treat the content as raw binary data, typically triggering a file download. It's used as a fallback when no specific MIME type applies.
Why is charset important in MIME types?
The charset parameter (e.g., 'text/html; charset=utf-8') specifies the character encoding of text content. Without it, browsers may guess the encoding incorrectly, causing garbled text. UTF-8 is the recommended charset for modern web content as it supports all Unicode characters.