TRIM WHITESPACE

Clean the spacing problems that make matching, sorting, and importing fail: spaces at the start or end of a value, double spaces, invisible characters copied from web pages, line breaks inside cells, and empty rows or columns. Pick the options you want and the tool reports how many cells it changed.

Zero retention: your files never leave this browser. Verify it yourself in DevTools.

Loading the CSV tools.

About Trim CSV whitespace

How Can You Verify That Your Files Never Leave This Browser?

You do not have to take our word for it. Browser developer tools list every request a page makes, so you can watch 2csv work and confirm that your data is never sent anywhere. The check takes about a minute.

  1. Open your browser developer tools with F12, or Cmd+Option+I on a Mac, and select the Network tab.
  2. Reload the page and let it finish. You will see the page's own files (including the background file parser), its web fonts, and one anonymous page-view request. No file has been chosen yet, so none of them can contain your data.
  3. Click the clear icon in the Network tab so that the log is empty.
  4. Open a CSV file in the Trim CSV whitespace tool above, run it, and download the result.
  5. Look at the Network tab again. It is still empty. Reading, changing, and saving the file made no request at all. For extra proof, turn on offline mode after the page loads: every tool keeps working.

Your file is read into this tab's memory with the browser's own file reader, parsed and changed by code that is already on the page, and handed back to you as a download. It is never uploaded, never stored in the browser, and gone when you close the tab. The only other request the site can make is the feedback form, and only when you submit it.

The production site also sends a Content-Security-Policy header that tells your browser to refuse connections to anywhere except this site and the anonymous analytics endpoint, so even a bug could not send your data elsewhere.

Which Cleanups Can You Choose?

  • Trim spaces at the start and end of every value.
  • Turn double spaces into one space.
  • Remove invisible characters: zero-width spaces, soft hyphens, and stray byte-order marks. Non-breaking spaces become normal spaces.
  • Replace line breaks inside cells with a space.
  • Remove empty rows, and remove empty columns that have no value in any row.
  • Clean header names too, so column names lose the same stray spaces.

Each option is independent, so you can trim ends without touching line breaks, for example. After the run the tool reports how many cells, rows, and columns each option changed, which tells you how messy the file really was.

Why Do Invisible Characters Matter?

An invisible character is a character that takes no visible space but is still part of the value. Zero-width spaces and non-breaking spaces often arrive when text is copied from a web page or a word processor. Two cells that look identical then fail to match, so duplicates survive, filters miss rows, and lookups in other systems fail.

Removing them before you remove duplicates or filter is one of the most useful cleanups you can run, because the problem cannot be seen in the grid at all. The reported count tells you how many cells were affected, which is often more than expected.

In What Order Should You Clean a File?

  1. Run the CSV validator to see which problems the file has.
  2. Trim whitespace and remove invisible characters.
  3. Convert columns to clean numbers or dates with the column type converter.
  4. Remove duplicates last, once values are consistent enough to match.

Every step works on the table already in the tab, so the jobs chain without reloading. Undo keeps the last five changes, and Reset to original returns to the file as first read.

Is Trimming Safe for Every Column?

For almost every column, yes. Spaces at the ends of names, emails, and codes are nearly always accidental. Be careful only with fixed-width codes where a space is meaningful, and with notes columns where line breaks inside a cell are intended. In those cases leave that option off, or undo the change.

What Else Can You Do With a CSV Here?

  • CSV viewer: Open a CSV of any size, scroll every row, and see a profile of each column.
  • Sort CSV: Sort rows by one or more columns, as text, numbers, or dates, ascending or descending.
  • Filter CSV: Show only the rows that match an expression such as price > 10 AND state = "NY".
  • CSV validator: Find ragged rows, broken quotes, bad headers, encoding problems, and values of the wrong type.
  • Remove duplicates from CSV: Find and remove duplicate rows, comparing whole rows or only the columns you choose.
  • Find and replace in CSV: Find text in one column or every column and replace it, with match case, whole cell, and regex options.
  • Remove rows from CSV: Delete rows by number or range, the first or last rows, empty rows, or rows that match a rule.
  • CSV editor: Edit cells, add or delete rows, and add, delete, rename, or move columns.
  • Split CSV column: Split one column into several at a delimiter, such as a full name into first and last.
  • Merge CSV columns: Join two or more columns into one with the separator you choose, skipping empty values.
  • CSV column type converter: Convert a column to clean numbers, ISO dates, true/false, or upper, lower, or title case.
  • CSV to JSON converter: Convert CSV to a JSON array of objects or arrays, or to JSON Lines, with typed values.
  • JSON to CSV converter: Convert a JSON array or JSON Lines to CSV, flattening nested objects into dotted column names.
  • CSV to SQL converter: Turn a CSV into SQL INSERT statements, with an optional CREATE TABLE, for PostgreSQL, MySQL, SQLite, or SQL Server.
  • CSV to TSV converter: Convert a comma-separated file to tab-separated values that paste cleanly into spreadsheets.
  • TSV to CSV converter: Convert a tab-separated file to a standard, properly quoted comma-separated CSV.
  • CSV splitter: Split a large CSV into smaller files of a set number of rows, with the header repeated in each.

All eighteen tools are on the 2csv home page, and once a file is open you can switch between them without reloading it. Part of the 2suite.io privacy-first ecosystem.

Frequently Asked Questions

What is a non-breaking space?

A space character that looks normal but is a different character, so values with it do not match values with a normal space. The tool turns it into a normal space.

Does trimming change the header row?

Only if you tick Clean header names too. Then column names get the same trimming as the data.

Will it remove a column that is mostly empty?

No. Remove empty columns only removes columns with no value in any row. A column with one value is kept.

Can I undo a cleanup?

Yes. Undo keeps the last five changes, and Reset to original returns to the file exactly as it was first read.

Does trimming remove line breaks inside a cell?

Only if you tick Replace line breaks inside cells with a space. Otherwise multi-line values, such as notes or addresses, keep their line breaks.

Was this helpful?