How to Remove Nonbreaking Spaces From Text

A nonbreaking space looks much like an ordinary space, but it tells a layout engine to keep the words on either side together. It can arrive in text copied from a web page, document, or formatted report and cause unexpected search, sorting, or replacement results.

What is a nonbreaking space?

A nonbreaking space (often abbreviated NBSP) is a whitespace character that prevents a line break at that position. It is useful in typesetting, such as keeping a number and unit together, but can be inconvenient in plain-text lists or when matching text exactly. Because it is visually subtle, a line may look normal even when its characters differ.

Ordinary space cleanup does not necessarily replace every whitespace character. FastTextCleaner’s extra spaces tool targets regular spaces and tabs between words; it is not an NBSP-specific find-and-replace tool. Use an editor that can search for nonbreaking spaces or Unicode characters when you need to normalize them deliberately.

A safe way to find and replace them

  1. Make a copy first. Keep the original text so you can restore it if a broad replacement changes layout or content.
  2. Confirm the character. If a value will not match even though it looks identical, test a short sample in an editor that can reveal invisible characters or search for a nonbreaking space.
  3. Replace selectively. In a text editor with Unicode-aware find and replace, replace the NBSP character with an ordinary space. If you cannot enter or select that character reliably, use the editor’s documented special-character search feature rather than a guessed sequence.
  4. Check the boundaries. Review numbers with units, currency, dates, names, and phrases where a line break may be intentional. Some nonbreaking spaces are part of the desired typographic layout.
  5. Run only needed cleanup. After replacement, use a tool to remove repeated ordinary spaces if appropriate, then verify a sample against the source.

Do not confuse invisible spaces with every hidden character

Zero-width characters, tabs, and line endings are different from nonbreaking spaces and may need different treatment. A find-and-replace that removes all invisible characters can accidentally join words, damage identifiers, or change the structure of copied data. Make one change at a time and inspect the output.

Use the right cleanup for the text

For ordinary spaces and line-edge whitespace, FastTextCleaner offers browser-based cleanup controls. For NBSP-specific normalization, use a suitable editor, then keep the original nearby and compare the result. If the text came from a PDF or web page, see our guides to cleaning PDF text and cleaning copied web text.

NBSP cleanup requires identifying the character first; do not assume every formatting tool treats it as a regular space.