正在加载,请稍候…

MIME Types: What They Are and How to Use Them

Learn about MIME types (media types), how they work in HTTP headers, and find the right type for any file extension.

What Is a MIME Type?

A MIME type (Multipurpose Internet Mail Extensions type, also called Media Type or Content Type) is a label that identifies the format of data. Originally created for email attachments, MIME types are now used everywhere data format identification is needed — HTTP responses, file uploads, data URLs, and HTML.

MIME Type Syntax

MIME types follow this format:

type/subtype
type/subtype; parameter=value

Examples:

  • text/html — HTML document
  • text/html; charset=UTF-8 — HTML with encoding parameter
  • application/json — JSON data
  • image/png — PNG image
  • multipart/form-data; boundary=something — Form data with boundary

MIME Type Categories

text

Human-readable text content:

  • text/plain — Plain text
  • text/html — HTML markup
  • text/css — CSS stylesheets
  • text/javascript — JavaScript (though application/javascript is more accurate)
  • text/csv — CSV data

image

Visual content:

  • image/jpeg — JPEG photos
  • image/png — PNG with transparency
  • image/gif — Animated GIFs
  • image/webp — Modern efficient format
  • image/svg+xml — SVG vector graphics
  • image/avif — AV1 Image File Format (modern, high efficiency)

audio

Sound content:

  • audio/mpeg — MP3 audio
  • audio/ogg — Ogg Vorbis
  • audio/wav — Uncompressed audio
  • audio/aac — AAC audio
  • audio/webm — WebM audio

video

Video content:

  • video/mp4 — MP4 video
  • video/webm — WebM video
  • video/ogg — Ogg Theora

application

Non-text binary or structured data:

  • application/json — JSON data
  • application/xml — XML data
  • application/pdf — PDF documents
  • application/zip — ZIP archives
  • application/gzip — Gzip compressed
  • application/octet-stream — Unknown binary (generic binary)
  • application/x-www-form-urlencoded — HTML form data

multipart

Composite content with multiple parts:

  • multipart/form-data — File upload forms
  • multipart/mixed — Email with attachments

MIME Types in HTTP

The Content-Type header tells the recipient what format the response body is in:

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8

{"status": "ok"}

The Accept header tells the server what formats the client can handle:

GET /api/users HTTP/1.1
Accept: application/json, text/plain, */*

Content-Type in HTML Forms

HTML form encoding is controlled by the enctype attribute:

<!-- URL-encoded (default) -->
<form method="post" enctype="application/x-www-form-urlencoded">

<!-- Required for file uploads -->
<form method="post" enctype="multipart/form-data">

Common MIME Type Pitfalls

application/octet-stream

The generic binary type. Browsers download rather than display files with this type. Use specific types for correct browser handling.

text/javascript vs. application/javascript

Both are widely used; modern spec recommends text/javascript. In practice, both work in browsers.

application/x-www-form-urlencoded vs. multipart/form-data

For API POST requests with JSON body, use application/json. Use multipart/form-data only when uploading actual binary files.

MIME Sniffing

Some browsers ignore the declared Content-Type and "sniff" the actual content to determine the type. This can be a security risk. The X-Content-Type-Options: nosniff header prevents this behavior.

File Extensions to MIME Types

Common mappings:

Extension MIME Type
.html text/html
.css text/css
.js text/javascript
.json application/json
.png image/png
.jpg image/jpeg
.pdf application/pdf
.zip application/zip
.mp4 video/mp4
.mp3 audio/mpeg

Using the MIME Types Reference Tool

Our tool:

  1. Search by extension — find the MIME type for any file extension
  2. Search by MIME type — find the file extension for any MIME type
  3. Browse categories — explore all types in a category
  4. Copy type — one-click copy for use in code
  5. See browser support — which types browsers handle natively

Essential reference for web developers setting Content-Type headers, handling file uploads, and configuring web servers.