How to use this CSV Formatter
Paste your CSV data into the input area and click Format CSV. The tool
will normalize rows, trim surrounding spacing from values, pad shorter rows where needed,
and produce a cleaner CSV output that you can copy or download.
- Paste raw CSV text into the input area.
- Click Format CSV.
- Review the cleaned CSV output.
- Copy or download the result.
Example input
name, age, city
John,30,New York
Sara,25,London
Example formatted output
name,age,city
John,30,New York
Sara,25,London
Cleaning CSV can quietly change the data
"Formatting" CSV usually means trimming stray whitespace and lining up rows, and both steps
can alter meaning. Under RFC 4180 the spaces inside a field are part of the value, so
trimming " 007" to "007", or collapsing a deliberately padded
code, is a data change, not a cosmetic one. Most of the time trimming is what you want — but
if leading or trailing spaces are significant in your data, be aware a formatter will remove
them.
The safe mental model is that a CSV formatter normalises presentation: consistent
quoting, consistent row width, tidy structure. It should not, and this one does not, try to
reinterpret what your values mean — it will not turn true into a boolean or
01234 into a number, because CSV has no types and guessing them is how data
gets corrupted.
Padding short rows can hide the real bug
When a row has fewer columns than the others, a formatter pads it out so the grid is
rectangular. That produces neat output, but it can mask the actual cause. A row that is
short — or, more tellingly, one that is too long — is usually the symptom of an
unquoted comma inside a value, or an embedded newline that split one logical record across
two physical lines.
If you pad the ragged row and move on, you have straightened the symptom and kept the
corruption. Before accepting normalised output, it is worth looking at which rows needed
padding and asking whether a value contains a stray delimiter that should have been quoted
in the first place.
Delimiters, quoting, and line endings
A formatter has to assume a delimiter, and this one assumes a comma. Files exported in
European locales frequently use a semicolon instead, because the comma is
the decimal separator there — feed such a file in and every line collapses into a single
column. Tab-separated data has the same issue. Check the delimiter before formatting.
Quoting is where correctness lives: a value containing a comma, a double quote, or a newline
must be wrapped in double quotes, and inner quotes doubled (""), per RFC 4180.
The same standard specifies CRLF line endings between records, though most
tools accept plain LF. A field may legitimately contain a newline when quoted,
so a formatter that splits on line breaks without honouring quotes will break multi-line
cells apart.
Formatting does not sanitise dangerous cells
Tidy output is not safe output. If a cell's text begins with =,
+, -, or @, a spreadsheet may execute it as a formula
when the file is opened — CSV injection. Formatting rewrites structure; it does not neutralise
these payloads. If the CSV contains values that originated from users and will be opened by
someone else, sanitise those cells (for example by prefixing a single quote) as a separate
step. And remember that leading zeros and long IDs survive intact in the file itself but are
re-mangled the moment a spreadsheet auto-detects types on open, so import as text when those
columns matter.
Frequently Asked Questions
Will formatting change my values?
It can. Trimming removes leading and trailing spaces, which RFC 4180 counts as part of a
field — so a deliberately padded value like " 007" loses those spaces. It
will not, however, reinterpret types: text stays text, since CSV has no type system.
Why was a row padded with empty columns?
Because it had fewer values than the widest row. Padding makes the grid rectangular but
can hide the cause — usually an unquoted comma or an embedded newline that split one
record. Check padded rows for a stray delimiter that should have been quoted.
My file uses semicolons — will this format it correctly?
Not as-is. This formatter assumes commas, so a semicolon-delimited file (common in
European locales, where the comma is the decimal separator) reads as a single column.
Convert the delimiter first.
Does formatting protect against CSV injection?
No. A cell starting with =, +, -, or
@ can run as a formula in a spreadsheet, and formatting does not remove that
risk. Sanitise user-derived cells separately before sharing the file.
Will leading zeros survive formatting?
In the file, yes — the formatter keeps the text exactly. The loss happens later, when a
spreadsheet opens the CSV and auto-converts 01234 to a number. Import as
text rather than double-clicking to preserve them.
How are commas and quotes inside a value handled?
Following RFC 4180, a value containing a comma, quote, or newline is wrapped in double
quotes and any inner quote is doubled, so a "b" c becomes
"a ""b"" c". This is what keeps columns aligned when values contain the
delimiter.