# .csv MIME Type: text/csv

> Tabular data as comma-separated values, defined by RFC 4180.

- MIME type: `text/csv`
- Extensions: .csv
- Also seen as: `application/vnd.ms-excel`, `text/comma-separated-values`
- Content-Type header: `text/csv; charset=utf-8`
- Compress in transit: yes

## Good to know

- Browsers on Windows often report a `.csv` upload as `application/vnd.ms-excel` when Excel is installed. Validate uploads by extension and content, not the reported type alone.
- Excel guesses the encoding of CSV files. Prepending a UTF-8 byte order mark (`EF BB BF`) makes it read accented characters correctly.
- To make the browser download rather than display the file, add [Content-Disposition: attachment](https://www.devkult.com/headers/content-disposition.md).

## Server configuration

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

```
text/csv csv;
```

### Apache (.htaccess or server config)

```
AddType text/csv .csv
```

### Express

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

### Python

```
import mimetypes

mimetypes.add_type("text/csv", ".csv")
```

### HTML file input

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

## FAQ

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

`text/csv`. You may also see `application/vnd.ms-excel`, `text/comma-separated-values`, but `text/csv` is the one to send.

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

`Content-Type: text/csv; 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

- [.xlsx — application/vnd.openxmlformats-officedocument.spreadsheetml.sheet](https://www.devkult.com/mime/xlsx.md)
- [.json — application/json](https://www.devkult.com/mime/json.md)
- [.txt — text/plain](https://www.devkult.com/mime/txt.md)

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