Skip to main content

Guides

Remove Non-Breaking Spaces and Hidden Characters in Excel

CleanPastedText editorial · Updated

Text workbench

Try it on your text

Cleaning mode

Removes invisible and unsafe characters while keeping more formatting.

Try a real example

Each sample contains a problem you cannot see.

Original

Pasted text

0 chars · 0 words

Cleaned

Ready to copy

0 changes

Text stays in this browser

Same words · No AI rewriting · No content logging

Why do these characters break Excel?

They look like spaces or nothing at all, but Excel treats each as a different character. A lookup for "Acme Inc" will not match "Acme" + non-breaking space + "Inc". The cells look identical, so the failure feels random.

CharacterCodeFormula
Non-breaking space160=SUBSTITUTE(A1, UNICHAR(160), " ")
Narrow no-break space8239=SUBSTITUTE(A1, UNICHAR(8239), " ")
Zero-width space8203=SUBSTITUTE(A1, UNICHAR(8203), "")
Soft hyphen173=SUBSTITUTE(A1, UNICHAR(173), "")
Byte order mark65279=SUBSTITUTE(A1, UNICHAR(65279), "")

One formula for the common cases

Nest the replacements, then trim:

=TRIM(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1, UNICHAR(160), " "), UNICHAR(8239), " "), UNICHAR(8203), ""))

Fill it down a helper column, copy the results, and Paste Special as Values over the original. UNICHAR is available in Excel 2013 and later.

Or clean the text before it reaches the sheet

Copy the column, paste it into the cleaner above, and copy the result back. The report lists every non-breaking space, zero-width character and soft hyphen it found, which also tells you where the data came from. See removing non-breaking spaces and removing zero-width spaces for the characters themselves.

Pasting ChatGPT or web text into Excel

Multi-line text pasted into one cell may spill across rows. Paste into the formula bar to keep it in one cell, or use Alt+Enter for a line break you type. AI text also contains the narrow no-break space more often than most sources. For the wider problem of copied text that will not behave, see sanitizing copied text for code, JSON and CSV.

Common questions

Frequently asked questions

Why is TRIM not working in Excel?

TRIM removes only the ordinary space, character code 32, and collapses repeated ones. A non-breaking space is character 160 and looks identical, so TRIM leaves it. Text pasted from web pages, Word, PDFs and some exports often contains it. Replace it with SUBSTITUTE before applying TRIM.

What is the formula to remove non-breaking spaces in Excel?

Use =TRIM(SUBSTITUTE(A1, UNICHAR(160), " ")). SUBSTITUTE swaps each character 160 for a normal space and TRIM then tidies leading, trailing and repeated spaces. In older versions without UNICHAR, CHAR(160) works for the same character on Windows.

Does CLEAN remove non-breaking spaces?

No. CLEAN removes the non-printing ASCII control characters with codes 0 to 31. It does not remove character 160, and it does not remove Unicode characters such as the zero-width space (8203), soft hyphen (173) or narrow no-break space (8239). Those need SUBSTITUTE, or a cleaner run before the paste.

How do I find which hidden character is in a cell?

Use =UNICODE(MID(A1, n, 1)) with n set to the position you suspect, or =LEN(A1) versus the visible length to spot extra characters. UNICODE returns 160 for a non-breaking space, 8203 for a zero-width space, 8239 for a narrow no-break space and 173 for a soft hyphen.

Can I clean many cells at once?

Yes. Put the formula in a helper column and fill down, then copy and paste the results as values. For a large block, paste the whole column into CleanPastedText first, copy the cleaned result back into Excel, and check the report to see which characters were found. Nothing is uploaded; processing happens in your browser.

Continue reading

Related guides & tools