← CSV Repair & Deduper (offline browser tool)

How to handle commas, quotes, and line breaks inside CSV values

The quoting rules that let a CSV field safely contain a comma, a quote character, or a line break — and what goes wrong when they're missing.

Before you work through this by hand: you can check your own CSV free and see which of these problems your file actually has — duplicate rows, near-duplicates, broken quoting, encoding damage. It runs in your browser tab, nothing is uploaded, and there's no signup or email.

The rule: quote any field with a comma, quote, or newline in it

The CSV standard (RFC 4180) says any field containing the delimiter (usually a comma), a double-quote character, or a line break must be wrapped in double quotes. For example, a company name like Acme, Inc. must be written as "Acme, Inc." — without the quotes, that comma would be misread as a column separator, shifting every field after it.

Escaping a literal quote character

If the value itself contains a double-quote character, it's escaped by doubling it: the value She said "hello" becomes "She said ""hello""" inside the file. This is the part people most often get wrong when hand-editing a CSV.

What happens when quoting is missing or wrong

An unquoted comma inside a field shifts every column after it for that row — the exact "uneven row length" problem covered in our broken-CSV guide. An unescaped quote character can make a spreadsheet program think a field opened but never closed, sometimes swallowing several following rows into one giant cell.

Generating CSVs safely

If you're writing CSV output yourself, use a library's CSV writer (e.g. Python's built-in csv module, or pandas.DataFrame.to_csv) rather than manually joining strings with commas — these libraries apply the quoting/escaping rules above automatically, which is easy to get wrong by hand.

$19 one-time payment. No subscription. If you'd rather skip the manual steps above, CSV Repair & Deduper (offline browser tool) automates the duplicate-finding and review step for you, entirely on your own device.

See CSV Repair & Deduper (offline browser tool) — $19 one-time

See all free guides