Web Development
MIME Types Explained: Common Content-Types for Web Developers
Understand MIME types such as application/json, text/html, text/css, image/png, and application/pdf, and learn how incorrect Content-Type headers break browsers and APIs.
In this article
MIME Types Explained: Common Content-Types for Web Developers
A MIME type describes the nature and format of content being transmitted or stored.
On the web, MIME types commonly appear in the HTTP Content-Type header.
Examples include:
text/html
application/json
image/png
application/pdfDuck Cloud's MIME Type Lookup lets you look up common media types by extension or type.
Why Content-Type matters
When a browser receives a response, it needs to know what the bytes represent.
A JSON response should not be mislabeled as HTML. A stylesheet should not be served with an unrelated media type. A downloadable PDF should identify itself correctly.
Incorrect types can cause:
- failed API parsing;
- browser console errors;
- stylesheets not loading;
- unexpected downloads;
- incorrect text encoding;
- security restrictions;
- broken previews.
Common web MIME types
Typical examples include:
| Content | Common MIME type |
|---|---|
| HTML | text/html |
| CSS | text/css |
| JSON | application/json |
| XML | commonly application/xml or an appropriate XML-based type |
| PNG | image/png |
| JPEG | image/jpeg |
| SVG | image/svg+xml |
application/pdf |
For less familiar formats, use the MIME Type Lookup rather than guessing.
File extensions and MIME types are different
A file extension is part of a file name.
A MIME type is metadata describing the content.
For example:
report.pdf
has a .pdf extension, while an HTTP response may declare:
Content-Type: application/pdfServers commonly infer types from extensions, but the extension itself is not the HTTP header.
JSON APIs
A JSON API should normally identify its response as JSON.
When frontend code reports an error such as Unexpected token <, one possibility is that the request received an HTML page—perhaps a login page or proxy error—while the application tried to parse it as JSON.
Use Duck Cloud's HTTP Header Checker to inspect the response headers of a public endpoint.
Then validate the actual body with the JSON Validator when appropriate.
Character encoding
Text media types may also need a character encoding.
UTF-8 is the standard choice for modern web content.
Encoding mismatches can produce corrupted punctuation or non-Latin text.
If your site supports Burmese, Japanese, Arabic, emoji, or other Unicode content, test the actual production response rather than assuming local files are enough.
File uploads
Applications should not trust a user-supplied filename alone when deciding what an uploaded file really is.
A file named photo.jpg does not prove that its bytes are a safe JPEG.
Secure upload handling may need:
- content inspection;
- size limits;
- extension allowlists;
- MIME validation;
- safe renaming;
- malware scanning where appropriate;
- storage outside executable web roots.
MIME metadata is useful, but it is not a complete security check.
JavaScript MIME types
Modern JavaScript is normally served with an appropriate JavaScript media type.
Legacy systems may expose older variations.
When troubleshooting script loading, inspect the browser console and response Content-Type.
Do not fix a server MIME problem by disabling browser security protections.
Fonts and media
Fonts, audio, and video use their own media types and may also interact with CORS and caching policies.
If a font works locally but not from a CDN, check:
Content-Type;- CORS headers;
- cache behavior;
- requested URL;
- response status.
Download behavior
A server may combine Content-Type with Content-Disposition to influence whether content displays inline or downloads as a file.
The two headers solve different problems: one describes the format, while the other can suggest presentation and filename behavior.
Debugging checklist
- Identify the actual file or response format.
- Look up the expected MIME type.
- Inspect the live
Content-Typeheader. - Check status code and redirects.
- Verify text encoding.
- Do not trust upload extensions alone.
- Test behavior in the target browser or API client.
- Configure CDN metadata correctly when serving static objects.
MIME types are small pieces of metadata that quietly control a great deal of web behavior. When a browser or API handles a file strangely, Content-Type should be one of the first things you check.