MULTILINE CSV FIELDS

Why CSV Rows Break Across Multiple Lines

A CSV record can legitimately occupy several physical lines when a quoted field contains a line break; rows break incorrectly when quote boundaries are missing or software splits raw lines instead of parsed records.

Open CSV Checker & Fixer
SHORT ANSWER

Treat quotes as the record boundary guide. A newline inside a properly quoted field belongs to that field. If a quote is unclosed, find the earliest broken record and repair it from the source. Use a CSV-aware parser for checking and splitting—never split the file with a plain line command.

Physical lines are not always CSV records

A physical line ends at a CRLF or LF byte sequence. A logical CSV record ends at a line break that is outside a quoted field. RFC 4180 explicitly permits CRLF inside an escaped field, and the W3C CSV guidance says line endings within escaped cells are not normalized.

This is common in address, notes, description, and support-message columns. A three-record file can occupy six physical lines and still be valid. Tools that count or split raw lines will overstate the record count and separate one customer's data into multiple files.

How valid multiline fields are escaped

Wrap the complete field in double quotes. Commas and line breaks inside those quotes are data. A literal double quote inside the field is written as two double quotes. The closing quote must appear before the delimiter leading to the next field or before the record-ending line break.

Do not add backslashes as a universal quote escape; common CSV uses doubled quotes. Some products define other dialects, so follow the receiver's documented quote and escape settings when they differ.

Why one missing quote damages later rows

If a field begins with a quote and never closes, a parser can treat later delimiters and line breaks as part of that same field. The first broken record is the likely cause; the cascade of uneven rows after it is a symptom. Search backward from the first reported width change rather than editing every affected line.

The safe repair depends on the original value. A note may need a closing quote, an internal quote may need doubling, or an accidental opening quote may need removal. An automatic tool cannot choose among those meanings without source evidence.

Split and process by parsed records

Use a CSV parser to iterate records, then write complete records to each output. Repeat the header in every part and serialize quoted multiline values correctly. Tools For CSV's splitter works from parsed records, so an embedded line break stays with its row.

After repair or splitting, compare logical record counts, field counts, and a few multiline values. Open the output with the receiving application's import workflow rather than trusting how a plain text preview wraps long cells.

Broken and corrected examples

Valid address spanning two physical lines

BROKEN OR RISKY
id,address,country
42,12 King St
London,GB
CORRECT OR SAFER
id,address,country
42,"12 King St
London",GB

The complete address is quoted, so its line break stays inside one Address field and one logical record.

A literal quote inside a multiline note

BROKEN OR RISKY
9,"Customer said "retry"
then left",closed
CORRECT OR SAFER
9,"Customer said ""retry""
then left",closed

Doubling the internal quotes prevents them from closing the field early.

How to fix it safely

  1. Run CSV Checker & Fixer and locate the earliest malformed quote or record-width change.
  2. Inspect that record in the source system and determine whether the newline is intentional and where the quoted field should close.
  3. Repair only that quote boundary on a copy, then parse again to see whether later errors disappear.
  4. Use Split CSV by Row Count for size limits so complete logical records—not physical lines—stay together.

Common questions and edge cases

Are line breaks allowed inside a CSV cell?

Yes. Under the common RFC 4180 convention, a field containing a line break is enclosed in double quotes.

Why does wc -l report more rows than Excel?

A line counter sees every physical newline. A CSV parser treats newlines inside quoted fields as cell content, so its logical record count can be lower.

Can I replace every newline inside quotes with a space?

Only if your data policy says line breaks are disposable. That changes cell content; preserving and correctly quoting them is the safer default.

Can I split a CSV with the Unix split command?

Not safely when quoted fields may contain line breaks. Split parsed records and serialize them back to CSV instead.