CSV Formatter
Format, validate, and clean CSV data in your browser. Auto-detect delimiters, preview rows in a table, highlight issues, and download the normalized CSV.
What the CSV Formatter Does
The CSV Formatter turns messy spreadsheet exports and hand edited data files into clean, consistent CSV. Paste or upload your data and the tool detects the delimiter, parses every row while respecting quoted fields, normalizes the quoting, and shows the result as a table preview. It also runs a set of validation checks and reports rows with a different column count, empty or duplicate headers, and parse problems such as unclosed quotes. Everything happens in your browser, so sensitive exports never leave your device.
CSV looks simple until it is not. A single stray comma inside a company name, a missing quote, or a mixed delimiter from a European spreadsheet export is enough to break an import job. Formatting the file first catches these problems early, when the fix is a one line edit instead of a failed midnight batch job.
How to Use the CSV Formatter
- Paste CSV text into the input box or upload a .csv file. The sample buttons load a small example you can edit.
- Leave the delimiter on Auto-detect so the tool finds the field separator, or pick comma, semicolon, tab, or pipe yourself.
- Adjust the options: trim whitespace around fields, remove empty rows, and whether the first row contains column names.
- Read the stats and validation issues, then copy or download the formatted CSV from the output box.
How CSV Parsing Works in the Browser
A correct CSV parser cannot just split on commas, because a field may contain the delimiter inside a quoted string. The parser behind this tool implements the state machine described in RFC 4180: it tracks whether it is inside a quoted field, treats commas and line breaks inside quotes as literal characters, and reads a doubled quote as an escaped quote character. When it regenerates the file, fields that contain the delimiter, a quote, or a line break are automatically wrapped in quotes so the output round trips without changes in value.
Delimiter detection works by sampling the first lines and counting how often each candidate character appears outside quotes. The candidate with the most consistent count per line wins. This is why a pasted export using semicolons or tabs, common in locales where the comma is the decimal separator, is recognized without any manual setup.
What the Validation Checks Cover
- Column count mismatches. Rows with fewer or more fields than the header usually mean an unescaped delimiter or a missing quote. Each offending row is listed by number.
- Unclosed quotes. A quote that never closes swallows the rest of the file into one field. The parser reports where it noticed the problem.
- Empty header names. Blank column names break named column access in most import tools, so they are flagged.
- Duplicate headers. Two columns with the same name are ambiguous when data is imported into a database or mapped to JSON keys.
Formatting Rules the Tool Applies
The output is a normalized version of your input: consistent delimiter, consistent quoting, trimmed fields when the option is on, and empty rows removed when requested. Fields are only quoted when required, which keeps the file easy to read. The stats cards show how many rows and columns were parsed and which delimiter was used, so you can confirm the parser interpreted the file the way you expected before downloading it.
Once the file is clean, you can convert it further with the CSV to JSON converter, produce a spreadsheet with the CSV to Excel Converter, or just inspect the data with the CSV Viewer. If a specific problem remains, use Validate CSV for a structure focused report, or Find Incomplete CSV Records to list rows that do not match the header width.
Frequently Asked Questions
Which delimiters can the formatter detect?
Comma, semicolon, tab, and pipe. Auto-detect picks the character that appears consistently across the first lines outside quotes, and you can override the choice at any time from the delimiter dropdown.
Is my data uploaded anywhere?
No. Parsing, validation, and formatting all run in JavaScript inside your browser. The file never leaves your device, which makes the tool safe for customer lists, financial exports, and other sensitive data.
Can I upload a CSV file instead of pasting it?
Yes. Use the upload button on the input box to load a .csv or plain text file. The content is read locally with the FileReader API and appears in the input box where you can still edit it before formatting.
Why does a row show a column count error?
It means the row has a different number of fields than the header. The usual causes are a delimiter character inside a value that is not wrapped in quotes, a missing quote, or a genuinely incomplete record. The row number is reported so you can fix the source line.
What does the trim whitespace option do?
It removes leading and trailing spaces from every field after parsing, so values like " Ada Lovelace " become "Ada Lovelace". This is handy when a spreadsheet export pads cells, but turn it off if spaces inside values are meaningful.
Does the formatter change my values?
No. It only changes the file structure: delimiter, quoting, and optionally whitespace and empty rows. Field values are preserved exactly as parsed, and the output can be turned back into the original data without loss.
Is there a file size limit?
There is no fixed limit. Processing happens in your browser, so the practical ceiling depends on your device memory. Files with hundreds of thousands of rows generally work, though the table preview shows only the first 100 rows to stay responsive.