CSV Rows With the Wrong Number of Columns, Explained
Unlike a JSON syntax error, a CSV row with the wrong number of fields usually doesn't throw an error at all — it just produces JSON that's quietly wrong, which is more dangerous because nothing tells you to look.
What actually happens
CSV → JSON conversion maps each row's values to the header row's column names by position. If a row has fewer fields than there are headers, the missing trailing fields typically become empty strings. If a row has more fields than headers, the extra values are silently dropped — there's no header to attach them to.
name,age,city
Ada,30,Paris
Grace,28
Alan,35,Boston,USA
Converting that gives you {"name":"Grace","age":"28","city":""} for the second row (silently padded) and drops "USA" entirely from the third — no error, no warning, just data that doesn't match what was in the source file.
Why this happens so easily
The most common cause is an unescaped delimiter inside a field — a comma inside an address or free-text field that wasn't wrapped in quotes shifts every subsequent value in that row by one column. Spreadsheet exports and hand-edited CSVs are the usual sources.
How to catch it
- Check that fields containing your delimiter (comma, semicolon, etc.) are quoted in the source —
"Boston, MA"notBoston, MA. - After converting with CSV ⇄ JSON Converter, spot-check a few rows in the output against the source, especially any row where a field might reasonably contain the delimiter character.
- For a systematic check, count fields per row (e.g. in a spreadsheet) and compare against the header count before converting anything important.
Validate before mapping columns
Use a CSV parser rather than splitting each line on commas. Quoted fields can contain delimiters, escaped quotes, and line breaks, so one physical line is not always one record. Configure the expected delimiter, quote character, escape behavior, encoding, and whether a header is present. A parser using the wrong dialect can produce consistent-looking but incorrect columns.
For important imports, reject or quarantine rows whose field count differs from the header and report the record number plus a redacted excerpt. Do not silently discard extra values. After conversion, validate required fields and data types because a row can have the correct count while values remain shifted or malformed.
Frequently Asked Questions
Why does a row have too many columns?
An unquoted delimiter or malformed quoted field often shifts the remaining values.
Can a field contain a newline?
Yes, when it is quoted and parsed by a CSV-aware reader.
Should extra values be dropped?
No. Reject or quarantine the row unless the import contract defines a safe recovery rule.