CSV Format Reference

A concise reference for RFC 4180 CSV: delimiters, quoting, escaping, line endings and encodings.

RFC 4180 defines a CSV file as records separated by line breaks, with fields separated by commas. A field that contains a comma, a double quote or a line break is enclosed in double quotes, and a literal quote is doubled.

01The rules that matter

  • The delimiter is a single character; CSV uses a comma, TSV a tab and PSV a pipe.
  • A quoted field may contain the delimiter, a newline or a doubled quote.
  • Records end with CRLF, LF or CR; a UTF-8 BOM may precede the first field.
  • Cells are text: CSV has no types, so numbers and booleans are strings.

02Detecting a dialect

When the dialect is unknown, score each candidate delimiter by how consistently the column count holds across the sampled records and choose the most consistent one.

Frequently asked questions

Why are my numbers strings?
A CSV cell is text by definition; any typing is an inference applied afterwards.
What ends a record?
CRLF, LF or CR. The parser tolerates all three and reports mixed endings.

Sources

  1. RFC 4180 - Common Format and MIME Type for Comma-Separated Values (CSV) Files — IETF (accessed 2026-10-10)