2026-06-05Web Development
Understanding File Types: MIME Types Explained
MIME (Multipurpose Internet Mail Extensions) types are standardized identifiers that specify the nature and format of a document, file, or assortment of bytes. They are essential for proper file handling on the internet.
What is a MIME Type?
A MIME type consists of two parts: a type and a subtype, separated by a slash. For example:
text/html— HTML documentapplication/json— JSON dataimage/png— PNG imagevideo/mp4— MP4 video
Why MIME Types Matter
Web servers and browsers use MIME types to determine how to handle files:
- Content-Type Header: Servers send the MIME type in HTTP responses
- File Handling: Browsers decide whether to display, download, or prompt for files
- Security: Incorrect MIME types can lead to security vulnerabilities
- Validation: Applications use MIME types to validate uploaded files
Common MIME Types
Documents
| Format | MIME Type |
|---|---|
| application/pdf | |
| DOCX | application/vnd.openxmlformats-officedocument.wordprocessingml.document |
| TXT | text/plain |
| HTML | text/html |
Images
| Format | MIME Type |
|---|---|
| PNG | image/png |
| JPEG | image/jpeg |
| GIF | image/gif |
| SVG | image/svg+xml |
| WebP | image/webp |
Video/Audio
| Format | MIME Type |
|---|---|
| MP4 | video/mp4 |
| WebM | video/webm |
| MP3 | audio/mpeg |
| WAV | audio/wav |
MIME Type Sniffing
Browsers may "sniff" MIME types by examining file content when the Content-Type header is missing or generic. This can be controlled with the X-Content-Type-Options: nosniff header.
Testing MIME Types
When testing your application, use sample files with known MIME types to verify proper handling across your entire pipeline.
#mime#http#web#file-types