MIME types

What is a Mime Types?

A MIME type, also called a media type or content type, tells browsers and servers what kind of data a file contains, for example text/html, image/png or application/pdf. Sending the wrong type can make a browser download a page instead of displaying it, refuse to run a script, or block a stylesheet. This lookup converts between file extensions and MIME types in both directions.

How to use it

  1. Enter a file extension, such as webp, to find its MIME type.
  2. Or enter a MIME type, such as application/zip, to see its extensions.

Common MIME types

  • .html: text/html
  • .css: text/css
  • .js, .mjs: text/javascript
  • .json: application/json
  • .svg: image/svg+xml
  • .webp: image/webp; .avif: image/avif
  • .woff2: font/woff2
  • .csv: text/csv
  • .pdf: application/pdf
  • .xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • Unknown binary data: application/octet-stream

Structure

A MIME type has a type and subtype separated by a slash, optionally followed by parameters: text/html; charset=utf-8. Subtypes starting with vnd. are vendor-specific, and suffixes like +json or +xml indicate the underlying format.

Why it matters

  • With X-Content-Type-Options: nosniff, browsers refuse scripts and styles served with the wrong type.
  • File upload validation should not trust the extension alone; check the content as well.
  • Always include charset=utf-8 for text types to avoid garbled characters.

Frequently Asked Questions

What is the MIME type for JSON?

application/json.

What MIME type should JavaScript files use?

text/javascript is the current standard. application/javascript is also widely accepted.

What is application/octet-stream?

The generic type for arbitrary binary data. Browsers usually download such files instead of displaying them.

Why did my browser block a stylesheet?

It was probably served with the wrong Content-Type while the nosniff header was set. CSS must be served as text/css.

How do I check the MIME type a server sends?

Open the browser developer tools, select the request in the Network tab and look at the Content-Type response header, or run curl -I with the file URL.

Can I trust the MIME type of an uploaded file?

No. The type sent by the browser is based on the file extension and can be faked. Inspect the file content, for example its magic bytes, before accepting it.