text/csv MIME Type — CSV Downloads, Headers & Export Guide
Comma-Separated Values. A simple tabular data format where each line is a row and values are separated by commas (or semicolons in some locales). Universally supported by spreadsheet software. The standard format for data exports.
Used For
- Data exports from web apps
- Spreadsheet imports
- Analytics data downloads
- Bulk data transfer
HTTP Header Example
HTTP/1.1 200 OK
Content-Type: text/csv; charset=utf-8
Content-Disposition: attachment; filename="users.csv"
id,name,email
1,Alice,alice@example.com
2,Bob,bob@example.comCode Examples
// Express — CSV export endpoint
app.get('/export/users.csv', async (req, res) => {
const users = await db.users.findAll()
const csv = [
'id,name,email',
...users.map(u => `${u.id},"${u.name}","${u.email}"`),
].join('\n')
// Add UTF-8 BOM for Excel compatibility
const bom = '\uFEFF'
res
.set('Content-Type', 'text/csv; charset=utf-8')
.set('Content-Disposition', 'attachment; filename="users.csv"')
.send(bom + csv)
})Related MIME Types
Frequently Asked Questions
What is the text/csv MIME type?
Comma-Separated Values. A simple tabular data format where each line is a row and values are separated by commas (or semicolons in some locales). Universally supported by spreadsheet software. The standard format for data exports.
When should I set Content-Type: text/csv?
Set Content-Type: text/csv on HTTP responses that contain CSV data. Data exports from web apps.
What file extensions use text/csv?
Files with text/csv content typically use these extensions: .csv.
What happens if I serve this with the wrong Content-Type?
Browsers use the Content-Type header to decide how to handle the response. Serving text/csv content with an incorrect MIME type can cause browsers to display it incorrectly, refuse to execute it (scripts), or prompt an unintended download. Modern browsers respect X-Content-Type-Options: nosniff and will not attempt to auto-detect the type.
