Remove Spaces from TextNon-Breaking & Zero-Width Too

Remove regular spaces, tabs, and line breaks from pasted text. The tool also finds hidden characters such as non-breaking and zero-width spaces and lists how many it found.

Your input is never sent anywhere.

Details
Input text
0 chars

Quick presets

Custom options

Result

Enter text above and the cleaned result appears here

Why text that looks identical won't match in Excel

The tool removes regular spaces, full-width spaces, tabs, and line breaks. Each one is a separate option, so you can remove only the ones you want.

It also finds characters you cannot see. A non-breaking space (U+00A0) looks like a normal space but is a different character, and Excel's TRIM does not remove it. Text copied from a web page can carry them, so two cells that look the same may not match. When you paste, the tool lists each hidden character it found and how many.

You can delete hidden characters or turn special spaces into regular ones so the words stay apart. The result updates as you type, so there is no button to press.

When stray spaces cause problems

An Excel lookup or match fails

Text from web pages can carry non-breaking spaces that TRIM leaves in place. Paste the cell text to see the count, then convert or remove them.

Codes, IDs, and phone numbers

Strip every space and tab from product codes, serial numbers, or phone numbers that were copied with spacing.

Spaces at the edges of every line

Trim each line removes the leading and trailing whitespace on each line and keeps the spaces inside the line.

Text copied from Word, Google Docs, or a web page

Pasted text can include zero-width spaces, soft hyphens, and non-breaking spaces. The notice shows what came along.

How to clean text in 4 steps

  1. Paste your text into the Input text box.
  2. If the text contains hidden characters, a notice shows how many. Open Show details to see each type.
  3. Pick a preset, or set the options yourself under Custom options.
  4. Check the Result, which shows the character count and how many were removed, then click Copy result.

Note: There is no run button. The result updates every time you change the text or an option.

How each option behaves

  • Hidden characters: Remove hidden characters covers 21 characters, including the non-breaking space, zero-width spaces, the byte order mark, and the soft hyphen. It deletes them, so words that were separated by a non-breaking space join together. Use Convert hidden spaces to regular spaces to keep them apart.
  • Detection: the count and the breakdown are based on your input, whichever options are on.
  • Trim each line: it works line by line and also removes tabs and special spaces at the start and end of a line.
  • Collapse repeated spaces: runs of spaces, tabs, full-width spaces, and special spaces become one regular space. It has little effect while space removal is on.
  • Blank lines: a line that holds only spaces counts as blank only after the spaces are removed or the lines are trimmed.
  • Remove all line breaks: lines are joined with nothing between them.

Hidden space characters and what they do

Characters that look similar can behave differently when you compare, count, or search text.

CodeNameLooks likeWhere it shows up
U+0020SpaceA normal spaceThe standard space. Excel's TRIM handles it.
U+3000Ideographic (full-width) spaceA wide gapUsed in Chinese, Japanese, and Korean text. A separate character from a normal space.
U+0009TabAn indentSeparates columns when you copy cells from a spreadsheet. Also used for indentation.
U+00A0Non-breaking spaceSame as a spaceExcel's CHAR(160). Common in text copied from web pages. TRIM does not remove it.
U+200BZero-width spaceInvisibleHas no visible width but still counts as a character, so two strings that look the same can differ in length.
U+FEFFByte order markInvisibleCan sit at the start of a file saved with a BOM and end up in the first field when the file is read as plain text.
U+00ADSoft hyphenInvisible unless a line wrapsMarks where a word may break. It can stay in copied text.
U+202FNarrow no-break spaceA thin spaceA narrow variant of the non-breaking space, used in typesetting.

Why text that looks the same doesn't match

Excel's TRIM removes only regular spaces (character 32). A non-breaking space is character 160, so TRIM leaves it in place and a lookup or comparison against clean text can fail. In Excel the usual fix is =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). This tool does the same job on pasted text: it replaces the special spaces with regular ones and shows you what it found.

Tip: removing indentation is how code is minified, but it breaks languages where indentation is part of the syntax, such as Python and YAML. For those, use Fix hidden characters instead of removing spaces.

Tracking down hidden characters: LEN, TRIM, and BOM

How to confirm that hidden characters are the problem and which fix to use.

Compare lengths before you clean anything

When two values look the same but do not match, compare their lengths first. In Excel, LEN counts the characters in a cell. If one value is longer than it looks, a hidden character is in it.
Paste the text into this tool and the notice lists each hidden character and how many of it there are, so you do not have to guess which one it is.

Delete a non-breaking space or replace it with a space?

It depends on what the character is doing. At the start or end of a value, deleting it is fine. Between two words, deleting it joins the words, so a name like New York becomes NewYork.
Excel's own fix replaces it with a regular space: SUBSTITUTE(A2,CHAR(160)," "). In this tool, use Convert hidden spaces to regular spaces or the Fix hidden characters preset to do the same.

Zero-width characters and the BOM in files and code

Zero-width characters and the byte order mark (U+FEFF) have no visible width, so you cannot spot them in an editor. They can show up when text is copied from other apps, and they can cause failures in code and data files that read the text literally.
Paste the text here, remove the hidden characters, and compare the character count before and after to confirm that something was there.

Common space-cleaning mistakes

Cleaning with TRIM and the values still don't match

You run TRIM on a column copied from a web page and a lookup still fails. TRIM removes only regular spaces, so non-breaking spaces stay, and nothing on screen shows that they are there.

💡 See the solution▼
Paste the text into this tool to see how many hidden characters it has. Then use the Fix hidden characters preset, which turns special spaces into normal ones and removes zero-width characters.

Words joined after removing hidden characters

Remove hidden characters deletes a non-breaking space. If that character was the only thing between two words, the words run together.

💡 See the solution▼
Turn on Convert hidden spaces to regular spaces, or use the Fix hidden characters preset. The special space becomes a normal space, so the words stay apart.

Trimming only the ends of the whole text

A basic trim cuts only the start and end of the full text. On a multi-line paste, the lines after the first keep their leading spaces.

💡 See the solution▼
Use the Trim each line preset. It works line by line, so every line is cleaned and the spaces inside a line stay as they are.

Stripping the indentation from Python or YAML

Removing all spaces and tabs from code is safe for formats such as HTML, CSS, and JSON. In Python and YAML, indentation is part of the syntax, so the code stops running or the file stops loading.

💡 See the solution▼
For those, use the Fix hidden characters preset. It leaves ordinary spaces and tabs in place and cleans only the hidden characters.

Space remover FAQ

Q.What is a non-breaking space, and can this tool remove it?

Q.

A. A non-breaking space (U+00A0) looks like a normal space but is a different character. In Excel it is CHAR(160). It is common in text copied from web pages. Yes, the tool can remove it: turn on Remove hidden characters to delete it, or Convert hidden spaces to regular spaces to replace it with a normal space. When you paste text, the tool also lists how many of each hidden character it found.

Q.Why does Excel TRIM leave some spaces behind?

Q.

A. TRIM removes regular spaces (character 32) but not non-breaking spaces (character 160). Text copied from a web page can contain them, so two cells that look the same may not match. In Excel, the usual fix is =TRIM(SUBSTITUTE(A2,CHAR(160)," ")). Here, paste the text and use the Fix hidden characters preset to turn the special spaces into normal ones and remove zero-width characters.

Q.Which hidden characters does it detect and remove?

Q.

A. It handles 21 characters: the non-breaking space (U+00A0), the zero-width space, non-joiner, and joiner (U+200B to U+200D), the byte order mark (U+FEFF), the soft hyphen (U+00AD), the narrow no-break space (U+202F), the medium mathematical space (U+205F), the word joiner (U+2060), the Mongolian vowel separator (U+180E), and the spaces from U+2000 to U+200A. The notice above the presets shows the count and, in the details, how many of each type.

Q.Can I remove only regular spaces and keep tabs and other spaces?

Q.

A. Yes. Choose the Regular spaces only preset, or turn on just Remove regular spaces in Custom options. Tabs, full-width spaces, and hidden characters stay in the text. Each option works on its own, so you can combine them any way you like.

Q.How do I trim the start and end of every line?

Q.

A. Choose the Trim each line preset. It removes spaces, tabs, and other whitespace at the start and end of each line and leaves the spaces inside a line alone. It works line by line, so every line of a multi-line text is trimmed, not just the first and last.

Q.How do I collapse repeated spaces into one?

Q.

A. Choose the Collapse repeated spaces preset, or turn on Collapse repeated spaces. Runs of spaces, tabs, full-width spaces, and special spaces become one regular space. The preset also turns on Trim each line and Remove blank lines. If a space-removal option is on at the same time, there is usually nothing left to collapse, and the tool shows a notice.

Q.Can I remove all line breaks and make the text one line?

Q.

A. Yes. Turn on Remove all line breaks, or use the Remove all whitespace preset. Lines are joined with nothing between them, so the last word of one line runs into the first word of the next. If you want a space between lines, use the Replace with space mode in the Remove Line Breaks from PDF Text tool instead. To close only the gaps between paragraphs, use Remove blank lines.

Q.Is my text sent to a server?

Q.

A. No. The tool cleans your text with JavaScript in your browser, and the page has no upload step. Your text is held only in the page while it is open, and closing or reloading the page clears it.

Q.Is there a limit on how much text I can clean?

Q.

A. The tool sets no character limit. The result is recalculated each time you change the text or an option, so a very large paste can feel slower on an older device.

User Feedback & Request

Your feedback
makes this tool better.

Tell us which features you'd like, what should be fixed, or which new tool you'd like to see. An engineer reads every submission and uses it to guide development.

Send feedback