Skip to main content
SheetTidy

Remove extra spaces in Excel and CSV files

Trim stray, double and invisible spaces from every cell, or only the columns you choose, in one step.

  1. 1
  2. 2
  3. 3
  4. 4

Drop your Excel or CSV file here

XLSX, XLSM, XLS, ODS, CSV, TSV or JSON

Your file never leaves your device

How to use this tool

  1. Step 1: Open your file

    Drop an Excel or CSV file onto the tool. The file check tells you straight away how many cells contain extra spaces.

  2. Step 2: Choose what to fix

    Spaces at the start and end, double spaces and non-breaking spaces are fixed by default. Turn on line-break removal if you want multi-line cells joined into one line.

  3. Step 3: Limit it to some columns if needed

    Clean the whole sheet, or only columns such as Name and City, leaving notes or addresses exactly as they are.

  4. Step 4: Preview and download

    Every cleaned cell is highlighted in the After view. Download the result as Excel or CSV.

Why extra spaces cause so much trouble

A space you cannot see still counts. To Excel, “Pune” and “Pune “ are two different values, so a lookup returns #N/A, a filter lists the same city twice, Remove Duplicates keeps both rows and a pivot table splits one customer into two lines. Spaces before numbers can also stop a column from adding up, because Excel stores “ 1250” as text.

Most of these spaces arrive with the data: a web form that did not trim its input, a CRM export that pads fixed-width fields, or a table copied from a web page or PDF.

How to remove spaces manually in Excel

The TRIM function

  1. Insert an empty column next to the one you want to clean.
  2. In the first cell, enter =TRIM(A2) and fill it down.
  3. Copy the new column, then use Home › Paste › Paste Values to replace the original values.
  4. Delete the helper column.

TRIM removes spaces at the start and end of the text and reduces any run of spaces inside it to a single space. It works on one column at a time, so a sheet with ten text columns needs ten helper columns.

When TRIM does not work

TRIM only removes the normal space character (code 32). The most common culprit it misses is the non-breaking space (code 160), which web pages use heavily. Wrap it in SUBSTITUTE to convert those first:

=TRIM(SUBSTITUTE(A2,CHAR(160)," "))

Zero-width spaces (Unicode 8203) are invisible even when you click into the cell. Remove them with =SUBSTITUTE(A2,UNICHAR(8203),""). The CLEAN function removes non-printing control characters such as line feeds, but it does not touch either of these.

Find and Replace

Press Ctrl+H, type two spaces in Find what and one space in Replace with, then click Replace All repeatedly until Excel finds nothing. To target non-breaking spaces, click in Find what and type Alt+0160 on the numeric keypad. To remove line breaks, type Ctrl+J in Find what. Find and Replace cannot remove leading or trailing spaces on their own, so it is usually combined with TRIM.

Power Query

Transform › Format › Trim removes spaces at the start and end of each value, but unlike the worksheet function it does not collapse double spaces in the middle of the text.

Where this tool helps

Lookups that fail for no visible reason. A VLOOKUP or XLOOKUP between a price list and an order export returns #N/A for items you can see in both sheets. Trimming both files usually fixes it.

Importing into another system. CRMs, accounting software and email platforms often reject or duplicate records with padded fields. Cleaning before import avoids a second clean-up inside the other system.

Data copied from the web. Tables pasted from websites carry non-breaking spaces between words and at the ends of cells. They look normal but break sorting and matching.

Names typed by many people. Sign-up forms collect “Priya Shah”, “ Priya Shah” and “Priya Shah “. After trimming, Remove duplicates can recognise them as one person.

What the tool fixes

  • Leading and trailing spaces, including tabs and line breaks at the very start or end of a cell.
  • Double spaces and tabs inside text, reduced to one space.
  • Non-breaking spaces and other Unicode space characters, replaced with normal spaces, and zero-width characters, removed.
  • Line breaks inside cells, joined into one line, only if you switch that option on.
  • Header cells, so column names match exactly what other systems expect.

Cells that contain nothing but spaces become empty. Numbers, dates and text in other languages, such as Hindi or Gujarati, are otherwise left exactly as they were, and codes with leading zeros keep them.

Examples

Before After
“ Priya Shah” “Priya Shah”
“Rahul Mehta “ “Rahul Mehta”
“Shah Traders” with a non-breaking space “Shah Traders” with a normal space
“ 1250” (text) “1250” (text that a number conversion can now read)
“ “ an empty cell

Tips for a clean result

Run this tool before removing duplicates, so near-identical records with stray spaces are recognised as the same. If names also come in mixed capitals, follow it with the Change case tool. And if your file is a CSV that you plan to open in Excel, the CSV to Excel converter keeps leading zeros and special characters intact once the spaces are gone.

Frequently asked questions

Why does Excel's TRIM function not remove some spaces?

TRIM only removes the ordinary space character. Data copied from websites, PDFs and some accounting systems often contains non-breaking spaces (character 160) or zero-width characters, which look identical but are different characters. This tool replaces and removes those as well.

Will it remove the single space between first and last names?

No. Single spaces between words are kept. Only spaces at the start and end of a cell, and runs of two or more spaces inside it, are changed.

Are numbers and dates changed?

No. Only text cells are cleaned. Numbers, dates and true/false values are left exactly as they are.

Does it clean the header row too?

Yes, headers in the columns you choose are trimmed as well, because a header such as " Name " with hidden spaces breaks lookups and imports just like a data cell does.

What happens to a cell that only contains spaces?

It becomes a truly empty cell. That also helps the Remove blank rows tool recognise rows that only looked empty.

Can I keep line breaks inside cells?

Yes, they are kept by default. Turn on "Line breaks inside cells" only if you want multi-line text, such as addresses, joined into one line.

All clean tools