Invisible characters: what they are and how to get rid of them

Your text looks fine and behaves badly. These are the usual six culprits.

When a search finds nothing, two identical rows refuse to deduplicate, or a CSV import fails on the first column, the cause is usually an invisible character. The common ones are the non-breaking space (U+00A0), the zero-width space (U+200B), the byte order mark (U+FEFF) and the soft hyphen (U+00AD). They arrive by copy-paste and are impossible to see.

The six you will actually meet

CharacterCodeWhere it comes fromWhat it breaks
Non-breaking spaceU+00A0web pages, Word, PDF copy,  search, split by space, trim, number parsing
Zero-width spaceU+200BCMS editors, line-break hints, some generatorsexact match, deduplication, word count
Zero-width joinerU+200Demoji sequences, fancy text generatorscharacter count, string slicing, reversal
Byte order markU+FEFFfiles saved as UTF-8 with BOM in Notepad or Excelthe first CSV header, JSON parsing, shell scripts
Soft hyphenU+00ADPDF and Word hyphenationsearch inside words, spellcheck
Right-to-left markU+200Fpasted Arabic or Hebrew textdisplay order of surrounding text

The BOM deserves special mention because it produces the single most confusing error message in data work: a CSV where the first column header is id and nothing matches id. In Excel, save as CSV UTF-8 and you get a BOM; save as CSV (Comma delimited) and you get the system code page instead. Neither is plain UTF-8.

How to see them

Removing them without damaging the text

Word. Find and Replace, then in the Find field type ^s for a non-breaking space and ^- for an optional hyphen, replacing with a normal space and nothing respectively. Turn off AutoFormat as you type afterwards or Word puts some of them back.

Notepad++. Search mode Extended, find \xA0, replace with a space. For zero-width characters use Regular expression mode and [\x{200B}\x{200C}\x{200D}\x{FEFF}], replace with nothing.

Google Sheets. =CLEAN() only strips the first 32 control characters and misses U+00A0 entirely. Use =SUBSTITUTE(A2,CHAR(160)," ") and then =TRIM(). This is why TRIM alone so often appears not to work.

Excel. Same story: =SUBSTITUTE(A2,CHAR(160)," ") before =TRIM(). Find and Replace also works if you paste an actual non-breaking space into the Find box, which is awkward but reliable.

Python or a script. s.replace(chr(160),' ') for the space, and s.encode().decode('utf-8-sig') to drop a BOM while reading a file. In a shell, sed -i '1s/^\xEF\xBB\xBF//' file.csv removes the BOM from the first line only, which is the safe version — a global substitution would also delete legitimate U+FEFF characters further into the file.

Browser. Paste into a text cleaner that normalises whitespace and strips zero-width characters, then copy back. This is the fastest route when the text came from a PDF or a web page and you do not know what is in it.

What usually goes wrong

A standing rule for pasted text

Anything arriving from a PDF, a web page, a Word document or a chat message gets cleaned before it enters a spreadsheet, a database or a CMS. Three steps, in order: replace non-breaking spaces with ordinary spaces, strip zero-width characters, trim each line and collapse runs of whitespace.

Then count. If the character count still exceeds what you can see by more than the spaces you counted, something else is in there — usually a control character from a database export. At that point look at the bytes rather than guessing.

If you own the pipeline, do it once at the boundary instead of in every sheet: normalise input to NFC, map U+00A0 to a plain space, drop U+200B and U+FEFF, and reject anything still containing control characters below U+0020 other than tab and newline. Four rules, applied at the point data enters the system, remove the problem for everyone downstream.

The habit costs about fifteen seconds and removes an entire category of bug that is otherwise nearly impossible to diagnose, because the evidence is invisible by definition.

Related tools

Instagram caption lengthThe hard limit is 2,200 characters. The one that matters is the 125 you see…Remove duplicates in ExcelThree apps, four methods, and the one setting that silently deletes the wrong…Title case vs sentence caseThree style guides, three different answers, and the four-letter rule that…PDF text breaksThe file has no paragraphs to give you. Here is what it does have, and how to…Small capsSmall capital letters that paste anywhere plain text goes.Italic textTurn plain text into slanted Unicode letters you can paste anywhere — no…Username generatorReadable names built from real words. No xX_ padding, no forced digits.

See all text tools →

Frequently asked questions

What is a non-breaking space?

The character U+00A0. It looks like a space but prevents a line break at that point. It comes from web pages and Word, and it breaks search, TRIM and number parsing.

Why does TRIM not remove my spaces?

TRIM only handles the ordinary space U+0020. Replace CHAR(160) with a normal space first, then apply TRIM.

What is the BOM and why is it in my CSV?

The byte order mark U+FEFF, added when a file is saved as UTF-8 with BOM. It attaches to the first column header and stops it matching anything.

How do I see invisible characters?

Ctrl+Shift+8 in Word, Show All Characters in Notepad++, or compare the character count against the letters you can actually see.

Is it safe to strip all zero-width characters?

Not if the text contains emoji. Zero-width joiners hold multi-part emoji together, so target the zero-width space and the BOM instead.

Where do zero-width spaces come from?

CMS editors inserting line-break hints, some fancy text generators, and copy-paste from sites that use them to control wrapping.