How to Remove Extra Spaces in Excel and Google Sheets
Short answer: To remove extra spaces in Excel, use =TRIM(A1), then paste as values. If spaces remain, they are non breaking spaces (CHAR 160), which TRIM ignores. Kill those with Find and Replace (Alt+0160) or =SUBSTITUTE(A1,CHAR(160),” “). In Google Sheets use =TRIM(REGEXREPLACE(A1,”\s+”,” “)).
Pasted data, imported CSVs, and hand typed lists all arrive with the same flaw: double spaces, leading spaces, trailing spaces. They break VLOOKUPs, wreck sorting, and make filters miss matches. Every spreadsheet app has a cure. You just need the right one for your case. Written by the Quick Text Repeater Team. Last updated: November 2026.
Method 1: TRIM to Remove Extra Spaces in Excel (and Why It Is Not Enough)
TRIM is the first tool to reach for. In a helper column, enter:
=TRIM(A1)
TRIM cuts leading and trailing spaces and shrinks every run of spaces between words to one. Copy it down the column, then paste as values over the originals. Google Sheets has the same function with the same syntax. Microsoft’s own docs describe it plainly: it “removes all spaces from text except for single spaces between words” (Microsoft Support, TRIM function).
Its limit: TRIM only handles the normal space character (code 32). It does nothing to non breaking spaces (code 160), the unseen cause behind most “but I already trimmed it” complaints. It also cannot remove line breaks inside cells. For those, keep reading.
Method 2: Find and Replace for Double Spaces
For a fast cleanup with no helper columns:
- Select the range, or press Ctrl+A for the whole sheet.
- Open Find and Replace (Ctrl+H in Excel and in Google Sheets).
- Find: two spaces. Replace with: one space. Replace All.
- Repeat until it reports zero changes. Each pass collapses the next layer of triple and quadruple spaces.
Then handle the edges with TRIM from Method 1. Together they remove extra spaces in Excel in 90 percent of cases: Find and Replace for the middles, TRIM for the edges.
Method 3: Power Query Cleanup for Big Datasets
When the data is thousands of rows, or arrives dirty every week, stop fixing it by hand and build a cleanup that repeats:
- In Excel, select your data and go to Data, then From Table/Range, to load it into Power Query.
- Select the text columns. Go to Transform, then Format, then Trim (cuts leading and trailing spaces) and Clean (removes unseen control characters like line breaks).
- Close and Load. Next week, paste the new dirty data into the source table and hit Refresh. The cleanup runs again by itself.
Power Query’s Clean is the only built in Excel step that handles embedded line breaks and control characters, which neither TRIM nor Find and Replace touch. For weekly reports, this is the pro answer. Microsoft’s data cleaning guide covers the TRIM plus CLEAN plus SUBSTITUTE combo in detail (Microsoft Support, cleaning data).
Method 4: Google Sheets, TRIM plus REGEXREPLACE
Google Sheets has everything Excel has, plus regex:
- Basic: =TRIM(A1). Same as Excel.
- All whitespace at once: =TRIM(REGEXREPLACE(A1,”\s+”,” “)). The pattern \s+ matches every run of whitespace, including non breaking spaces and tabs, and swaps each run for one normal space. TRIM then cleans the edges. Google documents the function here: REGEXREPLACE, Google Docs Editors Help.
- Line breaks inside cells: =REGEXREPLACE(A1,”\n”,” “) or CLEAN(A1) for control characters.
That one mega formula is the Sheets power move. One pass handles normal spaces, non breaking spaces, tabs, and multiples.
The Hidden Culprit: Non Breaking Spaces (CHAR 160)
If you trimmed and replaced and still see ghost spacing, you are looking at CHAR(160), the non breaking space. It looks just like a normal space but it is a different character, so TRIM skips it and Find and Replace for ” ” misses it. It sneaks in from web pages (HTML’s ), Word documents, and many exports. Microsoft states this outright: “by itself, the TRIM function does not remove this nonbreaking space character” (Microsoft Support).
How to remove extra spaces in Excel from CHAR(160):
- In Find and Replace, hold Alt and type 0160 on the numeric keypad in the “Find what” box. This inserts the non breaking space. Leave “Replace with” empty or put a normal space. Replace All.
- Or use the formula: =SUBSTITUTE(A1,CHAR(160),” “) and TRIM the result.
In Google Sheets, the REGEXREPLACE mega formula above already handles it. Tip to confirm: =CODE(MID(A1,position,1)) shows the character code at any spot. 32 is a normal space. 160 is the imposter.
Frequently Asked Questions
Why does VLOOKUP fail even though the values look the same?
Unseen spacing gaps, like trailing spaces or CHAR(160), make “match” not match. Clean both columns with TRIM before you compare.
Does TRIM remove line breaks?
No. TRIM handles spaces only. For line breaks use Power Query’s Clean in Excel, or CLEAN / REGEXREPLACE with \n in Google Sheets. For pasted plain text with messy breaks, our line cleanup tool strips them in one pass.
How do I stop this instead of fixing it?
Use Data Validation to reject entries with leading or trailing spaces. For imports, route repeat data through Power Query so cleanup runs on its own.
What about extra spaces in pasted plain text, not spreadsheets?
For text outside Excel and Sheets, like pasted paragraphs, chat logs, or documents, use our line cleanup tool. It strips extra spaces, fixes line breaks, and evens out whitespace in one pass.
How do I check my cleanup worked?
To confirm you remove extra spaces in Excel completely, paste a sample into our character counter. Hidden characters show in the count even when your eyes cannot see them. If you test software inputs, our QA edge-case checklist covers hidden characters too.
Cleaning text outside a spreadsheet? Our line cleanup tool handles pasted text in one click. No formulas needed.








One Comment
Comments are closed.