# .pdf MIME Type: application/pdf

> Portable documents. Browsers display PDFs inline unless told to download them.

- MIME type: `application/pdf`
- Extensions: .pdf
- Content-Type header: `application/pdf`
- Compress in transit: no (already compressed)
- File signature: `25 50 44 46 2D`

## Good to know

- Add [Content-Disposition: attachment](https://www.devkult.com/headers/content-disposition.md) to force a download, or `inline; filename="…"` to display it with a sensible save name.
- PDFs can contain JavaScript and links; treat user-uploaded PDFs as untrusted.

## Server configuration

### nginx (inside the types block in mime.types)

```
application/pdf pdf;
```

### Apache (.htaccess or server config)

```
AddType application/pdf .pdf
```

### Express

```
res.set("Content-Type", "application/pdf");
```

### Python

```
import mimetypes

mimetypes.add_type("application/pdf", ".pdf")
```

### HTML file input

```
<input type="file" accept=".pdf,application/pdf">
```

## FAQ

### What is the MIME type for .pdf files?

`application/pdf`.

### What Content-Type header should a .pdf file be served with?

`Content-Type: application/pdf`. It's already compressed, so servers shouldn't gzip it.

### How can I tell if a file is really a .pdf?

Check its bytes rather than the extension: PDF files start with `25 50 44 46 2D` (`%PDF-`). On the command line, `file --mime-type name.pdf` does this for you.

## Related types

- [.docx — application/vnd.openxmlformats-officedocument.wordprocessingml.document](https://www.devkult.com/mime/docx.md)
- [.epub — application/epub+zip](https://www.devkult.com/mime/epub.md)
- [.txt — text/plain](https://www.devkult.com/mime/txt.md)

Open the interactive page: https://www.devkult.com/mime/pdf