.csv MIME type
Comma-separated valuestext & code
text/csvTabular 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 | text/csv; charset=utf-8 |
| Compress in transit? | Yes — enable gzip or Brotli |
Good to know
- Browsers on Windows often report a
.csvupload asapplication/vnd.ms-excelwhen 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.
Useful here: CSV to JSON converter
Serve .csv files with the right type
The response header to send:
Content-Type: text/csv; charset=utf-8
Most servers pick the type from the file extension. If yours sends the wrong one, map it explicitly:
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">
Check it
See what a server sends for a file, and what type a local file really is by its contents:
curl -sI https://example.com/file.csv | grep -i '^content-type:' file --mime-type file.csv
Frequently asked questions
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
Headers that go with it: Content-Type · Content-Disposition · X-Content-Type-Options