CSV cells with commas, quotes and line breaks
Two records, more than two lines. Keep commas and newlines inside their cells.
A CSV cell can contain a comma, a quotation mark or a line break. That does not make the file broken. It means the cell needs quoting, and counting text lines will not necessarily tell you how many records it contains.
Download the sample CSV. Open the CSV, JSON & YAML converter and upload it. The file has two records, even though one caption spans two lines:
name,caption
"Lee, Sam","First line
Second line"
Mina,"She said ""hello""."
Read the quotes before splitting a row
The comma in "Lee, Sam" belongs to the name. The line break between First line and Second line belongs to the caption. Neither starts a new field or record because it is inside the surrounding double quotes.
Inside a quoted cell, two consecutive double quotes represent one quotation mark. So "She said ""hello""." becomes the text She said "hello".. The outer quotes and doubled inner quotes are CSV syntax, not extra characters to keep in the value. These rules are described in RFC 4180's CSV format notes.
Splitting raw text on every comma or newline misses that distinction. Removing all quotation marks is not a repair either: it turns commas inside names into column separators.
Convert the sample and check its values
- Upload the sample, or paste the CSV above into the input editor.
- Set From to CSV and To to JSON.
- In Options, keep First row contains headers on and Detect numbers and booleans in CSV off. Set CSV delimiter to Comma if automatic detection has chosen incorrectly.
- Check the Code result. It should contain two objects, each with a name and a caption. Table gives a quick check of the two rows and columns.
The downloaded sample uses CRLF line endings, including the break inside the first caption. Its JSON output contains:
[
{
"name": "Lee, Sam",
"caption": "First line\r\nSecond line"
},
{
"name": "Mina",
"caption": "She said \"hello\"."
}
]
JSON displays the carriage return and newline as escape sequences. They still represent a line break in the string. If you paste the example from this page instead of uploading the file, your clipboard may supply LF-only line endings; seeing \n rather than \r\n can be expected. Download the checked JSON output for the CRLF version.
Test the return trip
Choose Use result as input to convert the JSON back to CSV. Keep all columns selected. The exported CSV quotes the comma, multiline caption and quotation marks again. Converting it back to JSON preserved both records and every field value in our check.
That is a data comparison, not a promise that every CSV file will return byte-for-byte unchanged. Quoting, final newlines and delimiters can be written differently. The tool also protects spreadsheet-formula-like values by default, which can intentionally add a leading apostrophe. Our sample has no such values; keep that protection on when opening untrusted exports in a spreadsheet.
When the comma really is a mistake
The broken example leaves the comma in the name unquoted. It has a two-column header and a three-field row, so the converter rejects the mismatch. Quote the whole name as "Lee, Sam" to fix it; do not delete part of the name.
The results record contains the expected values, round-trip check and rejected-input result from 26 October 2026. It tests this small fixture with the converter's parser, not every spreadsheet application's CSV import rules.