CSV Cleaner

Trim whitespace, fix encodings, and normalize line endings in CSV files

Clean messy CSV exports in your browser — strip the UTF-8 BOM, convert CRLF to LF, trim whitespace from every cell, collapse double spaces, and drop empty rows. Shows a before/after summary and re-quotes fields to RFC 4180. No upload. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is a BOM and why remove it?

A byte-order mark is an invisible character (U+FEFF) some editors prepend to UTF-8 files. It often turns the first header into something like id, breaking column matching in parsers. The cleaner strips it from the start of the file.

Clean up a messy CSV export

The CSV Cleaner fixes the small inconsistencies that break CSV imports: invisible byte-order marks, mixed line endings, stray whitespace around values, and blank rows. It parses your file with a quote-aware reader, applies the fixes you choose, and re-emits clean, normalized CSV with a before/after summary.

How it works

First, if BOM removal is on and the file begins with U+FEFF, that character is stripped. The cleaner counts CRLF (\r\n) sequences in the raw text so it can report how many line endings are normalized — the output is always written with LF. The text is then parsed into rows and cells with a parser that respects double-quoted fields and escaped quotes.

Each cell is optionally trimmed of leading and trailing whitespace, and runs of two or more spaces or tabs can be collapsed to a single space. Fully empty rows are dropped when that option is enabled. Finally each field is re-serialised and quoted only when it contains a comma, double quote, or newline, following RFC 4180 minimal-quoting rules.

Common problems this fixes

ProblemSymptomCleaning option
UTF-8 BOMFirst header reads id not id; column matching breaksBOM removal
Windows CRLF line endingsExtra blank rows in some parsers; \r visible at line endCRLF normalisation (always on in output)
Space-padded cells" London " does not match "London" in a JOINCell trimming
Double spaces in textInconsistent display and mismatched string comparisonsCollapse multiple spaces
Empty rows from spreadsheet exportExtra blank rows break row count assumptionsDrop empty rows

When to leave options off

Cell trimming is safe for most numeric and text data, but leave it off if leading or trailing spaces carry meaning. Fixed-format reference codes (for example " A1" where the space is structural), right-padded legacy identifiers, and whitespace-significant markup can all be broken by trimming.

Similarly, number inference is not part of this tool — it cleans formatting only, so numeric strings like "1,000" (with a comma thousand separator) remain as strings. Strip the comma in your downstream tool or preprocessing step.

Typical workflow

  1. Export your CSV from the source system (database, Excel, Google Sheets).
  2. Paste it here and enable the options that match the known issues (BOM and CRLF are almost always safe to enable).
  3. Read the summary — confirm the counts match what you expected. If BOM count is 0 but you were certain the file had one, the source was already clean.
  4. Download the cleaned file and import it into the target system.

Running the cleaner before a database import or a pandas read_csv call prevents the most common “column not found” and silent mismatches that only show up later in the data pipeline. All processing runs locally — nothing is uploaded.