Why MIME Types Matter
MIME (Multipurpose Internet Mail Extensions) types are the identifiers that tell browsers, servers, and other web clients exactly what kind of data is being transmitted over HTTP. Every HTTP response includes a Content-Type header that specifies the MIME type of the response body. This information is critical because it determines how the client processes the content: whether to render it as HTML, display it as an image, parse it as JSON, or prompt the user to download it as a file. An incorrect or missing MIME type can cause browsers to misinterpret content, trigger security warnings, break API responses, and prevent files from loading entirely. For web developers, server administrators, and API designers, knowing the correct MIME type for every format you work with is fundamental to building reliable, secure web applications.
MIME Type Structure
A MIME type follows the format type/subtype, optionally followed by parameters like charset. The type indicates the general category, and the subtype specifies the exact format.
| Type Category | Description | Common Examples |
|---|---|---|
| text/* | Human-readable text content | text/html, text/css, text/plain, text/javascript |
| image/* | Image data in various formats | image/png, image/jpeg, image/svg+xml, image/webp |
| audio/* | Audio data | audio/mpeg, audio/wav, audio/ogg, audio/aac |
| video/* | Video data | video/mp4, video/webm, video/ogg |
| application/* | Binary or application-specific data | application/json, application/pdf, application/zip |
| font/* | Font files | font/woff, font/woff2, font/ttf, font/otf |
| multipart/* | Multi-part messages | multipart/form-data, multipart/byteranges |
Step-by-Step: Using the MIME Type Lookup
Enter a File Extension or MIME Type
Open the MIME Type Lookup and type either a file extension (like .json or .png) or a MIME type (like application/json) into the search field.
View the Complete MIME Type
The tool displays the full MIME type, its common file extensions, a description of the format, and usage context. Both extension-to-MIME and MIME-to-extension directions are supported.
Browse by Category
Explore MIME types organized by category: images, documents, audio, video, fonts, archives, and application-specific types. This helps you discover related formats and choose the right one.
Copy the MIME Type
Copy the exact MIME type string to use in your server configuration, Content-Type headers, or application code. The output is ready to paste into Apache, Nginx, or any framework.
Essential MIME Types for Web Development
Common Use Cases
API Responses
Set the correct Content-Type for JSON, XML, and other API response formats to ensure clients parse responses correctly and avoid CORS issues.
Web Server Config
Configure Apache, Nginx, or other web servers to serve files with the correct Content-Type headers for optimal browser behavior and security.
File Uploads
Validate uploaded file types using MIME type detection. Set the correct Content-Type when storing and serving uploaded files back to users.
Security Policies
Prevent MIME sniffing attacks by setting X-Content-Type-Options headers and using correct Content-Type values to stop browsers from guessing content types.
Setting MIME Types in Web Servers
Tip: Always set charset for text types - For text-based MIME types, include the charset parameter: text/html; charset=utf-8. This prevents encoding issues with international characters.
Tip: Use application/octet-stream as a last resort - Only use application/octet-stream when you genuinely do not know the file type. It forces the browser to download the file instead of displaying it.
Tip: SVG requires special handling - SVG files should use image/svg+xml, not text/xml or application/xml. Some servers need explicit configuration to serve SVG with the correct MIME type.
Best Practices for MIME Type Usage
- Always set the correct Content-Type header: Never rely on browsers to guess the content type. Explicitly set the Content-Type header in every HTTP response.
- Prevent MIME sniffing: Add the
X-Content-Type-Options: nosniffheader to prevent browsers from overriding your specified MIME type. - Use specific types over generic ones: Prefer
image/webpoverimage/*andapplication/jsonoverapplication/octet-stream. - Validate file types server-side: Never trust the MIME type sent by clients in file uploads. Validate the file content using magic bytes or library-based detection.
- Keep your MIME type database updated: New formats like AVIF, WebP, and WOFF2 are regularly added. Ensure your server configuration includes these newer types.
- Use modern image formats: Serve images in WebP or AVIF when possible for better compression and faster page loads.
Common Mistakes to Avoid
- Missing Content-Type header: Omitting the Content-Type header forces browsers to sniff the content type, which can lead to incorrect rendering and security vulnerabilities.
- Using text/javascript instead of application/javascript: While historically accepted,
application/javascriptis the officially registered MIME type. The MIME Sniff specification also defines it. - Serving SVG as text/xml: SVG should always use
image/svg+xml. Usingtext/xmlprevents browsers from rendering SVG inline and breaks CSP policies. - Trusting client-supplied MIME types: Attackers can modify the Content-Type header in file uploads. Always verify file types server-side using content inspection.
- Forgetting charset for text types: Not specifying
charset=utf-8for text-based types can cause encoding issues, especially with non-ASCII characters. - Using wrong types for modern formats: Use
font/woff2(notapplication/font-woff2) for WOFF2 fonts andimage/aviffor AVIF images.
Privacy and Security Considerations
MIME types have significant security implications for web applications. Improper MIME handling can expose your application to attacks and data breaches:
- Prevent MIME sniffing attacks: Browsers may ignore your Content-Type and interpret content differently. The
X-Content-Type-Options: nosniffheader prevents this by forcing browsers to respect the declared MIME type. - Validate uploaded file types: Never rely on the client-reported MIME type for file upload validation. Check file contents using magic bytes and store files with random names outside the web root.
- Restrict allowed MIME types: Maintain an allowlist of accepted MIME types for file uploads. Reject uploads with unexpected Content-Type values to prevent malicious file uploads.
- Use nosniff with JSON APIs: When serving
application/json, always includeX-Content-Type-Options: nosniffto prevent browsers from interpreting JSON responses as HTML, which could enable XSS attacks. - Client-side only processing: Our MIME Type Lookup tool operates entirely in your browser. No data is transmitted to any server, ensuring complete privacy.
Frequently Asked Questions
What is a MIME type?
A MIME (Multipurpose Internet Mail Extensions) type, also called Content-Type, tells the browser or client what kind of data is being transmitted. It follows the format type/subtype, such as text/html, image/png, or application/json. MIME types ensure browsers render content correctly and servers process uploads properly.
What is the most common MIME type for JSON?
The standard MIME type for JSON is application/json. Always use this Content-Type when returning JSON from APIs. The older text/javascript or text/json types are considered obsolete. For JSONP responses, use application/javascript instead.
Why is the correct MIME type important?
The correct MIME type ensures the browser interprets the content correctly. Using text/html for a JSON response can trigger XSS protection. Using the wrong image MIME type causes images not to display. Incorrect MIME types can also cause CORS issues, broken downloads, and security vulnerabilities.
What is the difference between application/octet-stream and specific MIME types?
application/octet-stream is a generic binary stream type used when the specific file type is unknown. It causes the browser to download the file instead of displaying it. Always use the specific MIME type (like application/pdf or image/png) when possible so the browser can handle the content appropriately.
How do I set the MIME type in an HTTP response?
Set the Content-Type header in your HTTP response. For example, in Node.js: res.setHeader('Content-Type', 'application/json'). In Apache, use the AddType directive. In Nginx, use the types block. Most web frameworks have middleware or configuration options for setting default MIME types.
Complete Web Development Suite
Enhance your web development workflow with these complementary tools:
HTTP Status Lookup
Look up HTTP status codes and their meanings
Base64 Encoder/Decoder
Encode and decode Base64 strings and data
HTML Encoder/Decoder
Encode and decode HTML entities for safe web display