# MIME Type Lookup

- **URL:** https://codeasystem.com/calculators/developer/mime-type-lookup/
- **Category:** developer
- **Description:** Look up the Content-Type MIME type for a file extension, with an honest fallback for extensions without a standard mapping.
- **Primary output:** .pdf: application/pdf

## Inputs
- File extension (name: `extension`, type: text, example: pdf)

## Outputs
- .pdf: application/pdf
- Type family: application
- Suggested Content-Type header: Content-Type: application/pdf

## Formula / methodology
```
extension → static MIME map (IANA media types)
```

The extension is trimmed of any leading dot, lowercased and matched against a curated map of roughly forty common media types. Unknown extensions return application/octet-stream with an explicit note instead of pretending to know.

## Assumptions & limitations
- Curated common-type table, not the full IANA registry.
- Some formats legitimately carry multiple MIME types (e.g. js).
- Servers may add charset parameters separately.

## How to use
1. **Type the extension**; pdf, PNG, .jpg; case and the dot do not matter.
2. **Copy the header**; Use the suggested Content-Type row directly in your server config or upload handler.

## Example
A .pdf file should ship with Content-Type: application/pdf so browsers render it with their built-in viewer instead of downloading it.

Result for these inputs:

```
.pdf: application/pdf
```

## About this calculator
### Why MIME types matter

Browsers decide whether to render, play, execute or download a response based almost entirely on its Content-Type header. A wrong type breaks image previews, triggers download prompts, or worse; lets an uploaded file be interpreted as HTML, opening XSS holes.

### The octet-stream fallback

application/octet-stream means “opaque bytes”: browsers will download rather than display. It is the correct honest answer for anything unrecognized, and safer than guessing a renderable type.

## FAQs
### Is it js or application/javascript?

Both appeared historically; current guidance favors text/javascript and modern browsers accept it universally.

### Do I need charset=utf-8 too?

For text/* responses, yes; append it (e.g. text/html; charset=utf-8) so browsers decode correctly.

### Where is the authoritative list?

The IANA media types registry at iana.org/assignments/media-types; our table covers the everyday subset.

## Related calculators
- [Port Number Lookup](https://codeasystem.com/calculators/developer/port-number-lookup/)
- [IP Address Format Converter](https://codeasystem.com/calculators/developer/ip-converter/)
- [Chmod Calculator](https://codeasystem.com/calculators/developer/chmod-calculator/)

---
Last updated: 2026-08-23 · Version: 1.0.0 · [HTML version](https://codeasystem.com/calculators/developer/mime-type-lookup/)
