Skip to main content
MyDataFixer

How to remove extra spaces and hidden characters from cells

By the MyDataFixer team · Updated

The short answer

A space at the start or end of a cell, like "Lyon ", is almost invisible, but Excel treats it as a different value from "Lyon". Use the TRIM function in Excel, Data → Data cleanup → Trim whitespace in Google Sheets, or Remove extra spaces in MyDataFixer's Spreadsheet Cleaner.

Why a small space causes big problems

To a person, “Lyon” and “Lyon ” look the same. To a spreadsheet they are two different pieces of text, because one has an extra character at the end. That small difference breaks many everyday tasks:

  • Lookups fail. VLOOKUP and XLOOKUP return #N/A because “Lyon ” isn't found in a list that contains “Lyon”.
  • Filters split values. The filter list shows “Lyon” twice, and you only see half the rows when you pick one.
  • Pivot tables and counts are wrong. The same city is counted as two different cities.
  • Duplicates are missed. Two rows that should be identical are not, so they aren't removed.
  • Numbers become text. “ 500” with a space in front may be treated as text, and it is left out of totals.

Where extra spaces come from

  • Typing: an extra tap on the space bar at the end of a name.
  • Copying from web pages, PDFs or emails, which often adds spaces or special invisible spaces.
  • Exports from other systems that pad values with spaces to a fixed width.

Text copied from web pages often contains non-breaking spaces. They look exactly like normal spaces, but they are a different character, and not every tool removes them. Some files also contain hidden control characters, such as stray line breaks or tab characters, which can break imports.

Example

The same city typed three ways (· marks a space)
city as typedwhat Excel sees
LyonLyon
·Lyona different value
Lyon··a different value

A count of orders per city would show three cities instead of one.

How to spot extra spaces

  • Click a cell and look at the formula bar: a space at the end shows as a gap before the cursor.
  • Use =LEN(A2) to count characters. “Lyon” has 4; if you see 5 or 6, there are extra spaces.
  • Compare with =A2=TRIM(A2). If the result is FALSE, the cell has extra spaces.

Fix it in Excel

These steps are for Excel on a Windows or Mac computer. The Excel app on phones and tablets doesn't have these menus; on a phone, use Google Sheets or MyDataFixer instead.

  1. Insert an empty column next to the column you want to clean (right-click the column letter → Insert).
  2. In the first data row of the new column, type =TRIM(A2), using the letter of your column.
  3. Double-click the small square at the bottom right of the cell to copy the formula down.
  4. Copy the new column, then right-click the original column → Paste Special → Values.
  5. Delete the helper column.

TRIM removes spaces at the start and end, and it also turns double spaces between words into single ones. It does not remove non-breaking spaces. For those, use this formula instead: =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). To remove hidden control characters, wrap it in CLEAN: =CLEAN(TRIM(A2)).

Fix it in Google Sheets

  1. Select the cells or columns to clean.
  2. Go to Data → Data cleanup → Trim whitespace.

This works directly on the cells, without helper columns. The TRIM function also works in Google Sheets, just like in Excel.

Fix it with MyDataFixer

  1. Open your Excel or CSV file in the Spreadsheet Cleaner.
  2. Choose Remove extra spaces. It removes spaces, tabs and non-breaking spaces from the start and end of every cell, and it keeps the spaces between words.
  3. Check the preview, which shows each cell before and after, then apply.
  4. Download the clean file.

For CSV files, the CSV Validator also finds hidden control characters and can remove them, with a preview first. Both tools work on phones and tablets, and your file stays on your device.

Clean spaces first, then everything else

Removing extra spaces is a good first step before other cleaning. After it, duplicates are found correctly, capitalization differences are easier to see, and numbers stored as text can often be converted.

How to avoid extra spaces next time

  • Paste as values. When copying from a web page, use Paste Special → Values (or Ctrl+Shift+V in Google Sheets) to leave most hidden formatting behind.
  • Use drop-down lists for values like cities or categories, so people choose instead of typing.
  • Clean imported data straight away, before you build formulas and reports on it.

Quick summary

Extra spaces are hard to see but break lookups, filters and duplicate checks. Find them with LEN or TRIM, remove them with TRIM in Excel, Trim whitespace in Google Sheets, or Remove extra spaces in MyDataFixer, which also removes non-breaking spaces and keeps the spaces between words.

Common mistakes

  • Using Find and Replace on all spaces. Replacing every space with nothing also joins words: “Asha Patil” becomes “AshaPatil”.
  • Keeping formulas instead of values. If you delete the original column while the TRIM column still holds formulas, the formulas break. Paste as values first.
  • Forgetting non-breaking spaces. If TRIM doesn't seem to work, the space is probably a non-breaking one.

Fix it in your browser

Free, no sign-up. Your file is processed on your device and never uploaded.

Questions and answers

How can I see extra spaces?

Click the cell and look at the formula bar, or use =LEN(A2) to count the characters: a higher number than expected means extra spaces.

Why doesn't TRIM remove some spaces?

They are non-breaking spaces, often copied from web pages. Use =TRIM(SUBSTITUTE(A2,CHAR(160)," ")) in Excel, or MyDataFixer, which removes them too.

Will removing spaces change my numbers?

No, it only removes the spaces. A number that had spaces around it may then be recognised as a number again.

Does MyDataFixer remove spaces between words?

No. It only removes spaces at the start and end of a cell. Spaces between words stay as they are.

Why does my VLOOKUP return #N/A when the value is clearly there?

Very often one of the two values has an extra space or a non-breaking space. Clean both the lookup value and the lookup list, then try again.

Can I remove extra spaces on my phone?

The Excel phone app has no Trim tool. Google Sheets in a browser has Data cleanup → Trim whitespace, and MyDataFixer's Spreadsheet Cleaner works on phones and tablets.

Does MyDataFixer upload my file?

No. Your file is cleaned in your browser, on your device.