csv guide

Quoted Commas and Newlines in CSV: Keep Each Value in Its Cell

Repair CSV field boundaries with original comma, double-quote and multiline examples, then verify the exact JSON values.

Published September 7, 2026 by SOLVEOZA Editorial

Quick answer

Enclose a CSV field in double quotes when its value contains a comma, a line break or a double quote. Inside that quoted field, write a literal double quote twice. A newline inside quotes belongs to the value, not to a new record.

Separate the value from the separator

In comma-delimited CSV, an unquoted comma starts another cell. North, West therefore looks like two values. Writing "North, West" keeps the comma inside one place name. The enclosing quotes describe the file structure; they are not part of the resulting value.

Choose Comma in CSV to JSON Converter for the examples below. If your export uses tabs or semicolons, select that delimiter instead. Changing the delimiter at random to make an error disappear can hide a broken export.

Three field-level rules
Desired valueCSV fieldWhy
North, West"North, West"Comma stays inside one cell
He said "ready""He said ""ready"""Each internal quote is doubled
Two lines in one note"line one line two"Quoted newline stays in the note

Try a complete two-record file

Copy the full CSV sample, including the header. Use First row as headers. The last note occupies two physical lines, but it is one field in the second data record. Expect two records and two columns, not three records.

Compare the generated JSON below with the original meaning. JSON uses a backslash-n escape to represent the embedded newline and backslash-quote escapes around ready. That display does not mean the converter inserted new text into the note.

Original CSV — two records
place,note
"North, West","He said ""ready"""
South,"line one
line two"
Expected JSON values
[
  {
    "place": "North, West",
    "note": "He said \"ready\""
  },
  {
    "place": "South",
    "note": "line one\nline two"
  }
]

Recognize a broken quote before guessing

The following input opens a quoted place field and never closes it. The converter rejects it. If the intended row was North, West followed by ready, the correction shown closes the place field before the column separator. Verify that meaning with the source; punctuation cannot recover missing records.

Do not replace every quote or strip all line breaks. Either operation can destroy meaningful content. Work on a sanitized copy and compare the number of records, number of columns and the actual values after each deliberate correction.

Invalid — unclosed field
place,note
"North, West,ready
Corrected for the stated meaning
place,note
"North, West",ready

Check the result as data, not just valid syntax

Success means the current converter accepted the input. Read both place values and both notes. Make sure ready still has its quotation marks and the South note still contains one newline. Use JSON Formatter to inspect the result, then check it against the intended records.

This guide addresses boundaries. Keeping an identifier such as 00127 is a separate concern covered in the leading-zeros guide. A valid file can still contain a misspelled heading or a value already altered by a spreadsheet.

RFC 4180 describes a common comma-separated format, but CSV exports vary. This tool also supports selected delimiters and is not a complete certification of every CSV dialect. If the source format is unclear, ask for its export settings before rewriting the data.

Methodology

  1. Author a two-record fixture containing all three quoted-field cases.
  2. Compare actual converter output to independent expected strings and verify unclosed-quote rejection.

Limitations

  • CSV dialects differ.
  • Parsing cannot reconstruct missing records.
  • A successful conversion does not verify source accuracy or application schema.

Sources

Original SOLVEOZA examples checked against the references below and the current tools. Sources explain the rules and do not endorse SOLVEOZA.

FAQ

Does every field need quotes?

Not for these simple comma-delimited examples. Quote fields containing commas, line breaks or double quotes; consistent quoting can also make exports easier to inspect.

Are single quotes a CSV quoting substitute?

Not in this workflow. The converter uses double quotes to enclose fields.

Why are there more lines than records?

A quoted field may contain a newline. Count parsed records rather than visual lines.

Can a successful conversion still be wrong?

Yes. Valid structure cannot establish that the chosen delimiter, headings or values match your source.

Continue the task