CSV Column Count CheckerFind Rows With Wrong Column Count

Paste a CSV or TSV file to find rows that have more or fewer fields than the first row. It also flags unclosed quotes and line breaks inside cells, and can save a copy with matching column counts.

Your input is never sent anywhere.

Details
Delimiter

What Causes Column Count Errors in CSV Imports

A CSV import usually stops when even one row has more or fewer fields than the others. Tools report it in different ways: phpMyAdmin says "Invalid column count in CSV input on line N", pandas raises "Expected 5 fields in line 3, saw 6", and PostgreSQL's COPY reports "extra data after last expected column" or "missing data for column". Finding that one row in a file with thousands of lines is the hard part.

Paste your data or drop a file and this CSV validator compares every row with the first row. It lists each row with a different number of fields, along with its record number and the line number you would see in a text editor. Delimiters and line breaks inside double quotes are not counted as separators, so "Austin, TX" is one field. It also flags unclosed quotes, line breaks inside cells, a UTF-8 BOM, and the file's encoding, and it can save a copy with every row padded or trimmed to match.

When to Check a CSV Before Importing

Debugging a failed database import

Paste the file you tried to load into MySQL, PostgreSQL, or phpMyAdmin. The table shows which rows are off, so you can fix them instead of guessing.

Cleaning data before a pandas or script load

Find the rows behind a pandas ParserError, or any script that stops at the first bad row, before you rerun the job.

Checking exports from Excel, Google Sheets, or a CRM

Spot stray commas, line breaks inside cells, and encoding problems in a spreadsheet or CRM export before you upload it to another system.

Reviewing TSV and semicolon-delimited files

Choose comma, tab, semicolon, or pipe, or let the checker detect it. Excel uses your regional list separator, so some exports come out semicolon-delimited.

How to Find the Bad Row in a CSV File

  1. Paste your CSV or TSV into the text box, or drop a file onto it. Use "Load file" to pick a file from your device.
  2. The delimiter is detected automatically. If the guess is wrong, pick the right one from the list.
  3. Read the stats and the mismatch table. Each row shows its record number, its line number, how many columns it has, and how far that is from the expected count.
  4. Open the file in a text editor, go to the line number, and fix the row. The record number skips blank lines and counts a multi-line cell as one row, so it can differ from the line number.
  5. To get a corrected file, choose "Save fixed copy". To keep a list of the problems, choose "Download error list".

Note: The first row sets the expected column count, whether it is a header or data.

What the Check Does and Doesn't Do

  • Expected count: The first non-empty row sets the expected number of columns. If that row is the wrong one, every other row is flagged. Fix or remove it first.
  • Quotes and line breaks: Delimiters and line breaks inside double quotes are not treated as separators, and two double quotes inside a quoted field count as one literal quote. CR, LF, and CRLF all end a row, and blank lines are skipped.
  • Encoding: A loaded file is read as UTF-8 first, and as Windows-1252 if the bytes are not valid UTF-8. UTF-16 LE files with a BOM are detected automatically. You can switch the encoding by hand after loading.
  • Saved copy: Short rows are padded with empty fields, and long rows are cut at the expected count, so the extra values are lost. Blank lines are not carried over. Review the copy before you import it.
  • Large inputs: Input over 5 MB shows a warning and may feel slow. The table shows the first 100 mismatches, and the error list download includes all of them.

CSV Import Error Messages and Their Usual Causes

Common error messages and symptoms, what usually causes them, and how to confirm and fix each one.

Error or symptomUsual causeHow to confirmFix
Invalid column count in CSV input on line N (phpMyAdmin)A value that contains a comma is not wrapped in quotesFind the row in the mismatch tableWrap the value in double quotes
Error tokenizing data. C error: Expected 5 fields in line 3, saw 6 (pandas)A row has more delimiters than the first rowCompare the row's column count with the expected countQuote the field that contains the delimiter, or remove the extra delimiter
extra data after last expected column / missing data for column (PostgreSQL COPY)A row has more or fewer fields than the othersCheck the Diff column: + means extra fields, - means missing fieldsRemove the extra fields or add the missing ones
Values land one column to the rightOne row has an extra or missing delimiterLook for +1 or -1 in the Diff columnFix the row, or save a fixed copy
Everything after one point ends up in a single cellAn unclosed double quoteRead the unclosed quote warning and its line numberClose the quote, or double any quotes inside the value
The first column name looks wrong (such as id)A UTF-8 BOM at the start of the fileLook for the BOM notice after loading the fileSave the file as UTF-8 without BOM
Accented letters look garbled (é shows as é)A UTF-8 file read as Windows-1252, or the reverseCheck the encoding label next to the file namePick the right encoding, then re-save as UTF-8

Why one bad row can stop the whole import
Many importers match each field to a table column by position, using the first row as the guide. When a later row has a different number of fields, the importer can't match it. Most tools reject that row or the whole batch, and how much gets rolled back depends on the tool.

The two most common causes
The first is an unquoted comma in a value such as 123 Main St, Austin or $1,000. The second is a line break inside a cell in a file exported from Excel or Google Sheets. The checker reports the two separately.

Delimiters, Quotes, and Encodings That Break CSV Files

Some import errors have nothing to do with the number of columns. These are the file-format details that cause the most trouble.

CSV vs TSV: more than the delimiter

A CSV file separates fields with commas and a TSV file separates them with tabs. In practice that changes how often you need quotes.
Commas show up inside values all the time: street addresses, company names like "Acme, Inc.", and numbers like 1,000. Every one of them has to be wrapped in double quotes, and one missed pair shifts that row's data.
Tabs rarely appear in values, so TSV usually needs fewer quotes. The downsides are that tabs are invisible when you read the file, and some editors convert them to spaces.
Excel uses your regional list separator, so in some regional settings a "CSV" file is actually semicolon-delimited. Use whichever format the system you are importing into expects.

BOM: why the first column name looks wrong

A UTF-8 BOM (byte order mark) is a 3-byte marker at the start of a file. Some programs read it as part of the first header, so id becomes \uFEFFid.
The column count is still correct, but lookups by header name fail, which makes this a confusing error.
Excel often needs the BOM to treat a CSV file as UTF-8 when you open it directly, while databases and scripts usually work better without it. A good rule is to use a BOM for files you will open in Excel and no BOM for files you will import. The checker shows when a loaded file has a BOM, and saved files get one only if you tick the option.

UTF-8 vs Windows-1252: why accented letters turn into garbage

Excel's plain CSV (Comma delimited) option commonly saves in a legacy Windows code page such as Windows-1252. Characters outside that code page can be replaced or lost on save. Most web apps and databases expect UTF-8, so names like José or Zoë come out garbled.
The fix is to save from Excel as CSV UTF-8 (Comma delimited), or to convert the file in a text editor. Excel's Unicode Text option saves a tab-delimited UTF-16 file, which the checker can also read.
The checker tries UTF-8 first, falls back to Windows-1252, and shows which one it used. Pick another encoding from the list if the text still looks wrong.

Common CSV Mistakes and How to Fix Them

Unquoted commas push the data one column to the right

A value such as Austin, TX or 1,000 contains a comma but is not wrapped in double quotes. The parser counts it as two fields, so every later value in that row lands one column to the right. Some importers accept the row anyway, and you notice only after the data is loaded.

💡 See the solution▼
Find the rows with +1 in the Diff column and wrap the affected value in double quotes. "Save fixed copy" cuts the extra fields off the end of the row and does not merge them back, so it can drop real data. Check the rows by hand first.

Line breaks inside cells split a record in two

A cell with a line break, such as a multi-line address or a notes field, is exported inside quotes, which is valid CSV. An importer that doesn't support this ends the row at the break, and the next line shows up as a row with too few columns.

💡 See the solution▼
The checker lists the records that contain line breaks. If your destination can't handle them, replace each break with a space or another character before you export. A record whose Line value is a range, such as 5-7, is the one that spans several lines.

An unclosed quote swallows the rest of the file

A stray double quote, often an inch mark as in 12" pipe or a character pasted in from another source, opens a quoted field that never closes. Everything after it is read as one field, so a file with thousands of rows can collapse into a few records.

💡 See the solution▼
Look for the unclosed quote warning above the results. It shows the line where the quote opens. Wrap the value in quotes and double the inner one, as in "12"" pipe", then check again. Column counts shown while the warning is active are unreliable.

Reading a Windows-1252 file as UTF-8, or the reverse

A file saved with Excel's plain CSV option can use a legacy code page. Importing it into a system that expects UTF-8 turns accented letters into garbage or question marks. The column count still matches, so the file passes validation and the damage shows up later.

💡 See the solution▼
Check the encoding label after loading the file. If it says Windows-1252, re-save from Excel as CSV UTF-8 (Comma delimited), or convert the file in a text editor. The BOM notice also tells you whether the first header could be misread.

CSV Troubleshooting FAQ

Q.What does "Invalid column count in CSV input" mean?

Q.

A. It means at least one row has a different number of fields than the others. phpMyAdmin reports it as "Invalid column count in CSV input on line N", and other tools word it differently, such as "Expected 5 fields in line 3, saw 6" in pandas. The most common cause is a value that contains a comma, like "123 Main St, Austin" or "$1,000", without double quotes around it. The next most common is a line break inside a cell. Paste your data into the checker and it lists every row whose column count differs from the first row, with its record number and line number.

Q.How do I find the row with the wrong number of columns in a CSV file?

Q.

A. Paste the data or drop the file into the checker. It counts the fields in every row and compares each one to the first row. Rows that differ appear in a table with their line number, column count, and the difference (+1 means one extra field, -1 means one missing). Open the file in a text editor, go to that line, and fix it. If you see an unclosed quote warning, fix that first, because it makes the results after it unreliable.

Q.Can it check TSV, semicolon-delimited, or pipe-delimited files?

Q.

A. Yes. You can choose comma, tab, semicolon, or pipe, or leave the setting on auto-detect. Auto-detect looks at the first few non-empty lines and picks the delimiter that appears most consistently from line to line. If the guess is wrong, select the delimiter yourself. Which delimiter you should use depends on the system you are importing into.

Q.Does it work with accented characters or files that aren't UTF-8?

Q.

A. Yes. When you load a file, the checker tries to read it as UTF-8 first. If the bytes are not valid UTF-8, it reads the file as Windows-1252, which is what Excel's plain "CSV (Comma delimited)" option commonly produces on Windows. UTF-16 LE files with a BOM are detected too. The encoding is shown next to the file name, and you can switch to UTF-8, Windows-1252, Shift-JIS, or UTF-16 LE if the text looks wrong. Text you paste is already decoded by your browser, so the encoding setting applies only to loaded files.

Q.Can it detect an unclosed double quote?

Q.

A. Yes. If a double quote is opened but never closed, everything after it is read as one field. The checker shows a warning with the line where that quote opens. Until you fix it, the column counts shown are not reliable. Close the quote, or write a literal quote inside a quoted value as two double quotes ("").

Q.Can it fix the column count automatically?

Q.

A. Partly. "Save fixed copy" pads rows that have too few fields with empty fields and cuts rows that have too many at the expected count, so the extra values are lost. Fields that contain the delimiter, a double quote, or a line break are wrapped in quotes, and blank lines are not carried over. This is a mechanical fix, not a repair of misplaced data, so review the copy before you import it. The expected count comes from the first row, so make sure that row is correct.

Q.Are line breaks inside a cell treated as errors?

Q.

A. No. A line break inside a quoted field is valid CSV, and the checker reads it as part of that field. It tells you how many records contain one, because some importers split the row at the break and then report a column count error. If your destination can't handle them, replace the breaks with a space or another character before you import.

Q.Why are there two row numbers, Record and Line?

Q.

A. Record counts data rows in order, starting at 1, and skips blank lines. Line is the line number you would see in a text editor. The two differ when a cell contains a line break or the file has blank lines. A record that spans several lines shows a range such as 5-7. Use Line to find the row in your editor.

Q.Does it check header names or data types?

Q.

A. No. It counts the fields in each row, checks quotes, and reports the file's encoding and BOM. It does not read header names, check data types, or compare the file against a schema. The first row sets the expected column count, whether it is a header or data.

Q.Is it safe to check a CSV file with private data?

Q.

A. Your data is not uploaded. The file is read, checked, and turned into a fixed copy inside your browser, and the tool has no upload step. The data stays in the page's memory until you close or reload the page.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback