The Basic Structure
CSV — comma-separated values — represents tabular data as plain text: each line is a row, and commas separate each row into columns. An optional first line commonly serves as a header, naming each column.
name,age,city
Alice,30,Boston
Bob,25,Chicago
The Standard: RFC 4180
CSV existed informally for decades before RFC 4180, published in 2005, formalized a standard version of the format — resolving inconsistencies between different tools' assumptions about line breaks, quoting, and delimiters. Not every CSV file in the wild is fully RFC 4180 compliant, but it's the closest thing to an authoritative reference for how CSV "should" behave.
Quoting Rules
A field must be wrapped in double quotes if it contains a comma, a double quote, or a line break — otherwise the parser would misinterpret that internal comma as a column separator:
1,"Johnson, Alice","Says ""Hello"" to everyone",true
Notice the escaped double quote: under RFC 4180, a literal double quote inside a quoted field is escaped by doubling it (""), not with a backslash. Backslash escaping is actually invalid under the RFC and will break compliant parsers expecting doubled quotes instead.
What RFC 4180 Doesn't Standardize
- Character encoding: the RFC predates widespread Unicode adoption and doesn't mandate one — UTF-8 is the de facto modern recommendation, but isn't formally required.
- Alternate delimiters: semicolon-delimited or tab-delimited files are common in the wild (semicolons especially in European locales, where a comma is already used as the decimal separator) but are technically outside the RFC 4180 comma-delimited standard.
A Detail That Trips People Up
Leading and trailing spaces inside a field are, strictly speaking, part of the value — RFC 4180 doesn't call for trimming them. A field like Boston (with a leading space) and Boston are technically different values under a strict reading, even though they might look identical at a glance.
Ready to see this structure rendered as an actual table?
Open CSV Viewer