# .txt MIME Type: text/plain

> Unformatted text. Also what many servers fall back to for files they don't recognise as binary.

- MIME type: `text/plain`
- Extensions: .txt
- Content-Type header: `text/plain; charset=utf-8`
- Compress in transit: yes

## Good to know

- Without `charset=utf-8`, browsers may guess the encoding and show accented characters as mojibake (Ã© instead of é).
- A script or stylesheet accidentally served as `text/plain` is blocked when `nosniff` is set.

## Server configuration

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

```
text/plain txt;
```

### Apache (.htaccess or server config)

```
AddType text/plain .txt
```

### Express

```
res.set("Content-Type", "text/plain; charset=utf-8");
```

### Python

```
import mimetypes

mimetypes.add_type("text/plain", ".txt")
```

### HTML file input

```
<input type="file" accept=".txt,text/plain">
```

## FAQ

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

`text/plain`.

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

`Content-Type: text/plain; charset=utf-8`. As a text format, include the charset so browsers don't guess the encoding. It compresses well, so let the server apply gzip or Brotli.

## Related types

- [.md — text/markdown](https://www.devkult.com/mime/md.md)
- [.csv — text/csv](https://www.devkult.com/mime/csv.md)
- [.html — text/html](https://www.devkult.com/mime/html.md)

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