How MIME types and the Content-Type header work
Every file served over the web carries a MIME type — a two-part label such as text/css or video/mp4. The part before the slash is the general type (text, image, audio, video, font or application), and the part after it is the specific subtype. Together they let a browser, email client or API know exactly what it received and how to handle it: render it, play it, display it, or offer it as a download.
On the web the MIME type travels in the Content-Type HTTP header, often with a charset, for example Content-Type: text/html; charset=utf-8. Servers usually decide the value by mapping the file's extension to a registered media type, so getting that mapping right matters: send a JavaScript file as text/plain and the browser may refuse to run it; send a PDF as application/octet-stream and it downloads instead of opening. The reference below lists common extensions in each category with their correct Content-Type.
Content-Type: image/svg+xml. The leading image tells the browser it is an image; the full type, image/svg+xml, tells it the bytes are an SVG vector drawn from XML — so it renders the markup rather than treating it as plain text or a raster bitmap.Frequently asked questions
- What is a MIME type?
- A MIME type (also called a media type or Content-Type) is a short label like text/html or image/png that tells software what kind of data a file or HTTP response contains. It has a type and a subtype separated by a slash, and it lets browsers and apps decide how to handle the content.
- What is the MIME type for JSON, PDF and SVG?
- JSON uses application/json, PDF uses application/pdf, and SVG uses image/svg+xml. These are the official IANA-registered media types, and using them ensures browsers and APIs interpret the files correctly.
- Where is the Content-Type used?
- The Content-Type is sent as an HTTP header with requests and responses to declare the body's media type, for example Content-Type: text/html; charset=utf-8. It is also used in email (MIME), form uploads (multipart/form-data) and the type attribute of script and style tags.
- What is application/octet-stream?
- application/octet-stream is the generic MIME type for arbitrary binary data of unknown kind. Servers use it as a fallback when no more specific type is known, and it usually prompts the browser to download the file rather than try to display it.
- Do MIME types matter for downloads?
- Yes. The Content-Type tells the browser whether to render a file inline or download it, and an incorrect type can cause a PDF to download as text or an image to fail to display. Pairing it with a Content-Disposition header gives you precise control over downloads.
- How do servers set the MIME type?
- Web servers map file extensions to MIME types using configuration (such as Apache mime.types or Nginx types blocks) and send the result in the Content-Type response header. Application frameworks can also set it explicitly when generating a response.