Glossary

CSV

CSV (Comma-Separated Values) is a plaintext format for tabular data, where each line is a record and fields within a record are separated by commas. It predates any formal specification by decades — different tools historically implemented subtly different quoting and line-ending rules — but RFC 4180 (2005) documents the common conventions most modern parsers follow.

How it works

Fields are separated by a delimiter (a comma by default, though ; and tab-separated TSV are common variants) and records by a line break. A field that contains the delimiter, a double quote, or a line break must be wrapped in double quotes, and a literal double quote inside a quoted field is escaped by doubling it:

name,age,bio
"Ada Lovelace",36,"Wrote ""notes"" longer than the paper they annotated"
"Grace Hopper",85,Computer scientist

The first line is conventionally, but not universally, a header row naming each column — nothing in the format itself distinguishes a header from a data row, so the convention has to be agreed on out of band. Unlike JSON or XML, CSV has no native way to represent nested structures — a row is always flat, which is exactly the tradeoff that makes it simple to open in a spreadsheet.

Common pitfalls

  • CSV has no official schema or type system — every value is text until the reader decides otherwise, so "007" and 007 are indistinguishable from a 7 unless the parser preserves leading zeros as a string.
  • Excel's default CSV handling silently reformats values that look like dates or drops leading zeros from things like ZIP codes or phone numbers.
  • Line-ending differences (\n vs \r\n) and delimiter differences (, vs ;, common in some European locales) between systems produce CSV files that look right but parse incorrectly elsewhere.
  • Embedded newlines inside a quoted field are legal per RFC 4180, but naive line-by-line parsers that don't track quote state will split one record into two.

Related terms

  • JSON — the usual target format when a flat CSV needs to become nested, structured data.
  • XML — another structured alternative, generally reached for when CSV's flat rows aren't expressive enough.

See also

  • Tool: CSV to JSON Converter — convert CSV text to a JSON array instantly, with header, delimiter, and type auto-detection options.