text/csv means: text/csv is the registered media type for Comma-Separated Values, a plain-text tabular format where each line is a record and fields are separated by commas. RFC 4180 codifies quoting, escaping and line-break rules so spreadsheets and programs exchange tables reliably. Text media types carry human-readable character data. Because they are text, the charset parameter matters: without an explicit charset=utf-8, receivers may guess a legacy encoding and mangle non-ASCII characters. Text types are also the ones browsers render or display inline, so the subtype decides whether content is treated as markup, code, or plain prose. You will encounter text/csv in contexts such as spreadsheet exports and imports between excel, sheets and databases; bulk data feeds, report downloads and etl interchange; simple tabular api responses where a full json structure is unnecessary. It is commonly associated with the file extension(s) .csv. Fields containing commas, double quotes or newlines must be wrapped in double quotes, and embedded quotes are doubled. There is no universal standard for the delimiter or encoding, so document whether you use commas, semicolons or tabs, and always specify charset.
When you'll see text/csv
- Spreadsheet exports and imports between Excel, Sheets and databases
- Bulk data feeds, report downloads and ETL interchange
- Simple tabular API responses where a full JSON structure is unnecessary
How to handle it
When serving a text type, always declare charset=utf-8 unless the specification fixes another encoding, and escape or sanitize content according to how it will be rendered. Treat text/html as executable: never inject untrusted strings into it without encoding. For text/plain and text/csv, preserve line endings and quoting rules so downstream parsers do not split fields incorrectly, and set Content-Disposition when you want a download instead of inline display. As a final checklist for text types: declare charset=utf-8 everywhere, normalize line endings for cross-platform consumers, escape output for the rendering context to prevent injection, and set Content-Disposition deliberately so browsers either display inline or download rather than guessing.
Notes & gotchas
Fields containing commas, double quotes or newlines must be wrapped in double quotes, and embedded quotes are doubled. There is no universal standard for the delimiter or encoding, so document whether you use commas, semicolons or tabs, and always specify charset.
Examples
POST /v1/resource HTTP/1.1
Host: api.example.com
Content-Type: text/csv; charset=utf-8
Content-Length: 36
id,name,role
1,Ada,admin
2,Grace,dev curl -i -X POST -H "Content-Type: text/csv; charset=utf-8" -d @payload.json https://api.example.com/v1/resource const res = await fetch("/data.csv", { headers: { Accept: "text/csv" } });
const text = await res.text();
const rows = text.trim().split("\n").map(line => line.split(",")); // use a real CSV parser for quoted fields import requests
with open("payload", "rb") as fh:
res = requests.post("https://api.example.com/v1/resource", data=fh,
headers={"Content-Type": "text/csv; charset=utf-8"}, timeout=30) Frequently asked questions
Is text/csv the same as application/csv?
application/csv is an unregistered alias some tools emit; text/csv is the IANA-registered type per RFC 4180. Prefer text/csv and declare charset=utf-8.
How do I represent a comma inside a CSV field?
Wrap the whole field in double quotes: "Smith, John". To include a literal double quote, double it: "He said ""hi""". Parsers following RFC 4180 handle this correctly.
Do I need to specify charset for text types?
Yes — append ; charset=utf-8 unless the type defines its own encoding rules. Without it, receivers may fall back to a legacy encoding and corrupt non-ASCII characters. UTF-8 is the safe default for the modern web.
What is the difference between text/plain and text/html?
text/plain is displayed verbatim with no markup interpretation; text/html is parsed as a document, executing styles and scripts. Serving user content as text/html when you meant plain text is a cross-site scripting risk.
Why do my non-ASCII characters appear corrupted?
The receiver guessed the wrong encoding because no charset was declared. Send charset=utf-8 in the Content-Type, ensure the bytes are actually UTF-8, and for HTML add a matching meta charset tag.
Try the CSV to JSON
Parse CSV into typed JSON with header and delimiter detection.