What Is This?
The text/csv MIME type indicates that the content is a Comma-Separated Values (CSV) file. CSV is a simple tabular data format where each line represents a row and commas separate columns. It is widely used for data export, import between spreadsheet applications, and data interchange with legacy systems.
Common Uses
Common Use
Data export from databases and analytics platforms
Common Use
Spreadsheet import/export (Excel, Google Sheets)
Common Use
Large dataset downloads for data analysis
Common Use
Bank statements and financial data exports
Examples
Serve files with the text/csv MIME type:
# Nginx
location ~ \.csv$ {
add_header Content-Type "text/csv";
}
# Apache
AddType text/csv .csvUse this MIME type in HTML or HTTP:
Content-Type: text/csv <!-- HTML reference --> <link rel="preload" href="file.csv" as="fetch" crossorigin>
Related Entries
More from this reference:
text/html
The MIME type for HTML documents, the standard markup language for web pages.
text/plain
The MIME type for plain text files with no formatting or markup.
text/css
The MIME type for Cascading Style Sheets used to style HTML documents.
text/javascript
The MIME type for JavaScript source files used to add interactivity to web pages.
Frequently Asked Questions
Should I include a BOM in CSV files?
Including a UTF-8 BOM (byte order mark) at the start of CSV files helps Excel correctly interpret UTF-8 encoding, especially when the file contains non-ASCII characters. Without the BOM, Excel may display characters incorrectly.
How do I handle commas within CSV fields?
Enclose fields containing commas, newlines, or double quotes in double quotes. Use two double quotes inside a quoted field to represent a literal double quote character. This is defined in RFC 4180.