The CSV File Format, Explained Simply

The CSV format is dead-simple on the surface — comma-separated values, one row per line — but the edge cases (quotes, escaped commas, line endings, encoding) are where most CSV bugs live. This guide covers the rules the RFC 4180 spec lays out so your files open cleanly in Excel, Sheets, and any database importer.

Generate matching mock data right now

No sign-up, runs 100% in your browser, exports straight to CSV.

The 5 core rules

  1. Each record is one line. Lines end with \r\n (Windows) per the spec, though \n (Unix) is widely accepted.
  1. Fields are separated by commas — no spaces around them.
  1. Optional header row comes first and names each column.
  1. Fields containing commas, quotes, or newlines must be quoted with double-quotes: "Hello, world".
  1. A double-quote inside a quoted field is escaped by doubling it: "She said ""hi""".

Encoding: always UTF-8

Use UTF-8 to handle accents, emoji, Cyrillic, Chinese, Arabic — anything outside ASCII. Some Excel versions need a UTF-8 BOM (byte-order mark) at the start of the file to detect it automatically. CSV.si exports UTF-8 by default.

What CSV does NOT support

Formulas, formatting (bold, color, fonts), multiple sheets, charts, cell merges, images, comments, data types beyond text. Numbers and dates are stored as strings; the program reading the file infers types.

Frequently asked questions

Is CSV the same as TSV?

TSV (tab-separated values) uses tabs instead of commas. Same idea, different delimiter, and TSV rarely needs quoting because tabs don't appear in normal text.

What is RFC 4180?

The informal IETF spec that documents how CSV should be formatted. Most tools follow it, but variations exist.

Should I include a header row?

Yes — it makes the file self-documenting and most importers expect one. Skip it only when the consumer explicitly says no headers.

Related guides

Start generating free mock CSVs

High-fidelity mock tables for tests, demos, or models. No sign-ups, completely local.