CSV to qCSV Converter
Convert CSV files to quoted CSV (qCSV) format. Force-quote all fields, escape embedded quotes per RFC 4180. Upload, paste, or type.
About
Standard CSV files often contain unquoted fields. This creates parsing ambiguity when field values contain the delimiter character, newlines, or double-quote characters. A mishandled comma inside an address field will shift every subsequent column in the row. The qCSV (quoted CSV) format eliminates this class of error by wrapping every field in double quotes (") and escaping any internal quote as "", fully conforming to RFC 4180 ยง2 rules 5-7. This tool performs real character-by-character parsing using a finite state machine, not naive string splitting. It auto-detects your delimiter and handles embedded newlines, which most spreadsheet exports silently corrupt.
Limitations: this tool assumes UTF-8 input. BOM-prefixed files are accepted but the BOM is stripped from output. Fields containing binary data or null bytes will be preserved but may render incorrectly in the preview table. For files exceeding 1 MB, processing runs in a background thread to keep the interface responsive. Pro tip: if your downstream system chokes on quoted numerics, use the "Smart Quote" mode, which only quotes fields that contain the delimiter, quotes, or newlines.
Formulas
The CSV parser operates as a Finite State Machine with four states. Each input character c triggers a transition:
The qCSV encoding function for each field f applies:
Where f is the raw field value, replace substitutes every occurrence of a double-quote character with two consecutive double-quote characters, and the result is wrapped in enclosing double quotes. The output row is then the concatenation of all encoded fields joined by the original delimiter delim.
Delimiter auto-detection counts occurrences of each candidate delimiter d โ {, ; \t |} across the first 5 lines, then selects the candidate with the lowest variance in per-line count and a non-zero mean, since a true delimiter appears consistently on every line.
Reference Data
| Scenario | Raw CSV Field | qCSV Output | Rule (RFC 4180) |
|---|---|---|---|
| Plain text | hello | "hello" | ยง2 Rule 5 - fields may be quoted |
| Contains comma | New York, NY | "New York, NY" | ยง2 Rule 6 - must quote if delimiter present |
| Contains double quote | Say "hi" | "Say ""hi""" | ยง2 Rule 7 - escape " as "" |
| Contains newline | Line1\nLine2 | "Line1\nLine2" | ยง2 Rule 6 - must quote if CRLF present |
| Empty field | (empty) | "" | ยง2 Rule 5 - quoted empty |
| Leading/trailing spaces | hello | " hello " | ยง2 Rule 4 - spaces are part of field |
| Numeric value | 42 | "42" | Force-quote mode wraps all |
| Boolean-like | TRUE | "TRUE" | Prevents type coercion in Excel |
| Tab delimiter input | A\tB | "A"\t"B" | Delimiter preserved, fields quoted |
| Pipe delimiter input | A|B | "A"|"B" | Delimiter preserved, fields quoted |
| Mixed quotes and commas | He said, "ok" | "He said, ""ok""" | Rules 6+7 combined |
| Unicode characters | ๆฅๆฌ่ช | "ๆฅๆฌ่ช" | UTF-8 passthrough |
| Field with only quotes | "" | """""" | Each " becomes "" |
| CRLF line ending | A\r\nB | "A\r\nB" | Embedded CRLF preserved inside quotes |
| Semicolon delimiter | A;B | "A";"B" | European CSV style supported |