A CSV file is plain text where commas separate the values. That works until a value itself contains a comma, such as the address "House 12, Road 5, Mirpur, Dhaka". If the comma is not protected, the reader sees four values instead of one and every column after it shifts. The same trouble appears with double quotes and line breaks inside a value.
This guide explains the one rule that protects them all, shows what a correct file looks like, and uses the free CSV to JSON converter to check a file and find the broken line.
The rule: wrap in double quotes, and double the quotes
The standard CSV format (RFC 4180) has two rules:
- A value that contains a comma, a double quote or a line break must be wrapped in double quotes.
- A double quote inside such a value is written twice.
So these values:
| What you mean | How it is written in the file |
|---|---|
Karim, Abdul |
"Karim, Abdul" |
Said "debug" first |
"Said ""debug"" first" |
House 12, Road 5 |
"House 12, Road 5" |
| A note with two lines | "Line one then a real line break then Line two" |
Rahim |
Rahim (no quotes needed) |
A file with all of them looks like this:
roll,name,address,note
101,"Karim, Abdul","House 12, Road 5, Mirpur",
102,Nusrat Jahan,Dhaka,"Said ""call first"" twice"
103,Rahim Uddin,Cumilla,"Line one
Line two"
Spreadsheet programs do this for you when you export, so a file saved from Excel or Google Sheets is normally correct. The trouble starts with files made by hand or by a script that simply joins values with commas.
Check a file with CSV to JSON
The converter follows the standard rules, so it is a quick way to see how any other program will read your file.
- Open CSV to JSON.
- Paste the CSV into "Paste CSV (comma, semicolon, tab or pipe separated)", or use Open file.
- Look at the Preview table under the output. Each header should have its values under it, and the Columns stat should match what you expect.
- Read the Warnings box. A broken row shows as "Line 3: Row has 4 fields, expected 3."
For the file above, the second record in the JSON output is:
{
"roll": 102,
"name": "Nusrat Jahan",
"address": "Dhaka",
"note": "Said \"call first\" twice"
}
The doubled quotes are read back as one quote, and the third record's note comes out as "Line one\nLine two", with the line break kept. The JSON writer escapes the quote as \", which is JSON's own rule and has nothing to do with CSV.
Mistakes that break a row
An unquoted comma
The line 102,Karim, Abdul,Ten in a file with three columns has four values. The converter still converts it, but it gives "class": " Abdul" and an extra column_4 key, and warns "Row has 4 fields, expected 3." The fix is 102,"Karim, Abdul",Ten.
A space before the opening quote
Look at 1, "x, y". The quote comes after a space, so the converter does not treat it as the start of a quoted value. The result is three values: 1, "x and y". Remove the space after the comma so the quote is the first character of the value.
Curly quotes instead of straight quotes
Word and some messaging apps turn " into “ and ”. These are different characters and CSV does not recognise them. A value such as “Hello, world” is split at the comma. Replace them with straight double quotes ("), and in Word turn off the autoformat that curls them.
A quote that never closes
If a value starts with " and the closing quote is missing, the converter has to guess where the value ends, and the answer is the end of the file. It reports an error such as "Unclosed quote — this field starts with " but never ends, so the rest of the file was read into it" and shows the line where the quote opened. That line is where you look.
A quote inside an unquoted value
A value like 5" pipe (the inch mark) with no quotes around the whole value is kept as it is. The tool does not complain, but other programs may. The safe way to write it is "5"" pipe".
Text after a closing quote
If a quoted value is followed by more characters before the next comma, such as "x"y, the converter keeps the extra text and warns "Unexpected text after a closing quote", so you can find it.
Writing CSV that is safe
If your data starts out as JSON, for example from an API, let a converter do the quoting rather than doing it by hand. In JSON to CSV, every value is checked: it is quoted when it contains the delimiter, a double quote or a line break, or when it begins or ends with a space, and quotes inside are doubled. The option "Quote every field" wraps every value, including numbers, in quotes, which some strict importers prefer. For the full list of options, read JSON to CSV: the complete guide.
The delimiter also matters. If you choose Semicolon, a comma inside a value no longer needs quotes, but a semicolon does. So changing the separator does not remove the rule, it only moves it.
If you are coming from Excel
Save the sheet as CSV and Excel adds the quotes itself. If you want to do it outside Excel, or you need the file in a particular delimiter, Excel to CSV lets you pick the sheet and delimiter and applies the same quoting. The guide to it is Excel to CSV: the complete guide. If Bangla text turns to question marks in the process, that is an encoding problem, not a quoting one, and it is covered in how to save Excel as CSV UTF-8 without breaking Bangla.
Quick checklist
- Wrap any value with a comma, a quote or a line break in double quotes.
- Write a quote inside a value as two quotes.
- Put no space before the opening quote.
- Use straight quotes, not curly ones.
- Paste the file into CSV to JSON and read the Warnings box.



