CSV Formatter

Paste a messy CSV and get it back written one consistent way: trimmed values, every row as wide as the header, and quotes only where a cell needs them. An aligned preview makes the columns easy to read.

How it works

The CSV is read in a background worker, with the separator detected from the first rows or picked by you. Every cell is read the way the CSV standard describes, so quoted commas, line breaks and doubled quote marks come through intact.

The rows are then written out again with one rule. By default a cell is quoted only if it holds the separator, a quote mark or a line break. You can choose to quote every cell instead. The separator and the line endings of your file are kept.

Trimming removes spaces at the start and end of each value. Filling adds empty cells to rows that are shorter than the header. Rows that are longer than the header are never cut, because that would delete data you have not seen; they are counted in the notes instead. Blank lines are dropped.

How to use it

  1. 1 Paste the CSV, open a file, or drop one onto the box.
  2. 2 Choose how to quote, and whether to trim values and fill short rows.
  3. 3 Read the notes: they say how many cells were trimmed and rows filled, and warn about rows with too many cells.
  4. 4 Copy or download the formatted CSV. Use the aligned preview only for reading.

Good to know

  • The aligned preview pads columns with spaces so they line up. Do not save it as your CSV: the spaces would become part of every value.
  • Quote every cell only if the program that reads the file asks for it. Most readers, Excel included, are happy with quotes only where needed.
  • If the notes say some rows have more cells than the header, open the CSV Validator to see which rows, then fix them at the source.
  • Leave trimming off when leading spaces mean something, such as fixed-width codes.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

One CSV, written one way: what a formatter can and cannot fix

A CSV that has passed through a few hands tends to collect small inconsistencies. One export quotes every cell and another quotes none. Someone typed a space after each comma. A row near the bottom lost its last two cells when a value was deleted. None of this stops a spreadsheet from opening the file, but each one can trip up a script, a database import or a diff between two versions of the same data.

Formatting means reading the file properly and writing it out again by one set of rules. Reading properly is the hard part. A cell can contain the separator, a line break, or a quote mark written twice, and a naive split on commas gets all three wrong. This tool parses each row the way the CSV standard, RFC 4180, describes, and detects whether your file uses commas, semicolons, tabs or pipes by checking which one gives every row the same number of columns.

Writing is then simple and predictable. With the default setting a cell is wrapped in quotes only when it needs them, which is when it contains the separator, a quote mark or a line break. Choose quotes around every cell if a strict loader expects that. The file keeps its own separator and its own line endings, so a Windows file stays CRLF and a semicolon file stays semicolon. To change the separator, use the CSV Delimiter Converter instead.

Two options change content, and both are off-switchable. Trimming removes spaces from the start and end of each value, which fixes " Lisbon" not matching "Lisbon" in a lookup. Filling adds empty cells to short rows so every row is as wide as the header; most importers reject a ragged file outright. A row that is wider than the header is the one thing the formatter will not touch. Cutting it would throw away values, and the formatter cannot know which ones are wrong, so it leaves the row whole and tells you how many there are.

The aligned preview is there so you can check the result with your eyes. It pads each column with spaces to the width of its widest cell, for the first 200 rows, and marks line breaks inside cells with ↵. Treat it as a view only. A CSV padded with spaces is a different CSV, because the spaces become part of every value. Copy or download the formatted CSV above it. Everything runs in a worker on your device, and the file is never uploaded.

Frequently asked questions

Will formatting change my values?

Only if you ask it to. With trimming on, spaces at the start and end of a value are removed. Quoting changes how a cell is written, not what it holds: "Lisbon" and Lisbon are the same value to any CSV reader.

What happens to a stray quote mark in the middle of a cell?

It is kept as part of the value, and the cell is written with proper quotes and the mark doubled (""), so strict readers accept it. The notes say how many cells had one.

Why is the aligned preview cut off?

It shows the first 200 rows, and cuts long cells at 40 characters, so it stays quick to read. Line breaks inside a cell show as ↵. The formatted CSV itself is always complete.

Is the file uploaded?

No. It is read and formatted in a worker on this page, on your device.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.