CSV structure guide

CSV Quoting, Delimiters, and Column Rules Explained

CSV structure comes from two decisions that must stay consistent: which delimiter separates fields and which values need quoting. Confirm the delimiter first, then check quote boundaries and row widths. When converting CSV to JSON, also verify that the first row contains unique, non-empty headers before assigning meaning to the values.

At a glance

Quick answer

  • Choose the actual delimiter before diagnosing the file; a comma, semicolon, or tab that is treated with the wrong setting changes the apparent column structure.
  • Quote a field when it contains the selected delimiter, a line break, or a double quote, and represent a literal quote inside a quoted field as two double quotes.
  • Every record should have the same number of fields as the first row for VetaTool validation, so missing, extra, and trailing delimiters are structural errors rather than cosmetic differences.
  • CSV-to-JSON uses the first row as trimmed property names, rejects empty or duplicate headers, and preserves cell values as strings unless a downstream schema explicitly converts them.

Identify the delimiter before reading the columns

CSV does not always mean comma-separated data. Exports commonly use commas, semicolons, or tabs, and the same character can also appear as ordinary data inside a quoted field. VetaTool parses the file with the delimiter selected in the toolbar, so choose the source delimiter before interpreting a row as too wide or too narrow.

Compare the header with one known-good data row. If both appear to be a single field even though the file is visibly tabular, the selected delimiter is probably wrong. If most rows have the expected width and only one row differs, the problem is more likely a missing or extra delimiter in that record.

Semicolon-delimited CSV

name;role;active
Ada;admin;true
Linus;editor;false

Quote delimiters, line breaks, and quotes that belong to a field

An unquoted delimiter ends the current field. If a comma is part of a notes value while comma is the selected delimiter, quote the whole field so the comma remains data instead of creating another column. The same rule applies to a physical line break that belongs inside one value.

A literal double quote inside a quoted field is written as two double quotes. VetaTool also requires a quoted field to begin with the quote at the start of that field; switching into quoted mode after unquoted characters is treated as malformed input.

Unquoted comma creates an extra column

name,notes
Ada,API, data
Linus,Kernel

Quoted comma stays inside one field

name,notes
Ada,"API, data"
Linus,Kernel

Literal quotes are doubled

name,notes
Ada,"Uses ""quoted"" text"

Keep closing-quote boundaries exact

Once a quoted field closes, VetaTool's CSV parser expects the selected delimiter, a record break, or the end of the file. Extra text between the closing quote and that boundary is ambiguous because the parser cannot know whether it belongs inside the value or outside the field.

That rule also means a space after a closing quote is not silently ignored by this parser. If spaces are meaningful data, keep them inside the quotes; if they are formatting noise, remove them before validating the record.

Valid quoted boundary

name,notes
Ada,"API work"
Linus,"Kernel work"

Match every record to one table width

VetaTool uses the first parsed row to establish the expected column count and then checks every later record against that width. A missing delimiter merges two intended values, while an extra or trailing delimiter creates another field. Either change can shift data into the wrong column during import even when the row still looks readable in plain text.

Blank physical rows and multiline values deserve special attention. A multiline value must stay inside a quoted field so its line break is data; otherwise the parser can interpret the next physical line as a new record with a different width.

Missing delimiter

name,role,active
Ada,admintrue
Linus,editor,false

Consistent columns

name,role,active
Ada,admin,true
Linus,editor,false

Validate headers before CSV-to-JSON conversion

CSV-to-JSON treats the first row as property names. VetaTool trims surrounding whitespace from each header, then requires every header to be non-empty and unique. That prevents an empty key or a repeated key from silently overwriting another column in the resulting object.

The converter keeps parsed cell values as strings. Values such as 00123, true, and 42 therefore remain textual CSV values rather than being guessed into numbers or booleans. Convert types only when the destination schema defines what each column means.

Headers and string values

account_id,active,count
00123,true,42

Use a repeatable CSV repair workflow

Start with the smallest failing records plus the header, select the delimiter used by the source, and run validation before converting the table. Repair the first confirmed quote or width error, validate again, and only then inspect header semantics or downstream type rules.

  • Confirm comma, semicolon, or tab before counting fields.
  • Check whether embedded delimiters, quotes, and line breaks are correctly enclosed and escaped.
  • Compare each failing record with the header width and a neighboring known-good record.
  • For CSV-to-JSON, make header names non-empty and unique after trimming whitespace.
  • Keep identifiers and other ambiguous values as strings until the receiving schema explicitly requires another type.