Text

Whitespace and Invisible Character Cleaner

Paste text that came out of a PDF, a Word document or a web page and it usually carries spacing you cannot see. This strips the extra spaces, the stray tabs and the invisible Unicode characters, and lists what it found so you know what was actually in there.

A line counts as blank when it holds nothing but spaces.

Tabs pasted between columns are usually what breaks a CSV.

Trimming lines and collapsing spaces both destroy indentation. Switch them off for code, Markdown and fixed-width tables.

0Characters in
0Characters out
0Removed
0Lines out

The whitespace you cannot see

A space is not always a space. Unicode defines more than a dozen characters that render as blank, and text copied out of a PDF, a Word document or a styled web page is full of them. They all survive a find-and-replace for a normal space, because they are not one.

The damage is always the same shape: two strings that look identical do not match. A spreadsheet lookup returns an error on a name you can see is correct. A JSON key fails to resolve. A pasted password is rejected. A CSV import puts a leading space in every field of one column.

Line endings, and why no tool in a text box can fix them

Windows ends a line with two characters, a carriage return then a line feed. Unix and macOS use the line feed alone. Classic Mac OS, before OS X, used the carriage return alone. Mixing them is what makes a file open as one enormous line in one editor and show a trailing ^M on every line in another, and what makes a diff claim every line changed when only one did.

Here is the part worth knowing: this tool cannot help you with that, and neither can any other page with a text box. HTML normalises the contents of a textarea to plain line feeds, so by the time a script reads what you pasted, the carriage returns are already gone. There is nothing left to count and nothing left to report. Line endings are a file-level problem, so fix them at file level — in your editor's line-ending setting, with dos2unix, or with git's own conversion setting.

Why collapsing spaces is sometimes the wrong move

Two of the options here are destructive in ways that are obvious in hindsight:

The rule of thumb: run this on prose. For code, turn off the line trimming and the space collapsing, keep the invisible character removal, and let your formatter handle the rest.

Removing invisible characters can break emoji

One of the characters in the invisible set is U+200D, the zero-width joiner, and it does real work. A single developer emoji is a person, a joiner and a laptop. Strip the joiner and you get two separate emoji instead of one. Family emoji fall apart the same way. If your text has emoji in it and they matter, switch that option off and clean the spaces only.

What this tool will not fix

It cannot read intent. A non-breaking space between a number and its unit, or inside a name, is deliberate typography — it is there to stop a line break splitting "10 km" in half. This tool replaces it with an ordinary space along with all the accidental ones. If you write carefully, compare before and after rather than trusting the output.

It also leaves the other invisible-difference problem alone: homoglyphs. A Cyrillic а and a Latin a are different characters that render identically, and no amount of whitespace cleaning will make them match. Same symptom, different cause, and worth ruling out when a string still refuses to compare equal after a clean.

Curly quotes, em dashes and ellipsis characters are left exactly as they are, because they are usually correct. And everything here runs synchronously in the page, so a paste of several megabytes will freeze the tab for a moment while it works. For files that size, a text editor with a regular expression search is the better tool.

Frequently asked questions

How do I remove double spaces from text?

Keep "Collapse repeated spaces" ticked and paste the text. Every run of two or more spaces becomes one. If you also want the spaces at the start and end of each line gone, leave "Trim each line" on as well.

What is a non-breaking space and why does it break things?

It is U+00A0, a space that stops a line from breaking at that point. It looks exactly like a normal space but is a different character, so exact-match lookups, form validation and string comparisons treat the two as different. That is why a spreadsheet can fail to find a name you can plainly see.

Will this remove line breaks entirely?

Not by itself. Set blank lines to "Remove all" and every empty line goes, but real line breaks between text stay. To join everything into one paragraph you would need to remove the line breaks too, which this tool deliberately leaves alone so your structure survives.

Is it safe to run this on source code?

Only with the line trimming and space collapsing switched off, since indentation is syntax in Python, YAML and Makefiles. Removing invisible characters is safe and genuinely useful on code, because a zero-width space pasted into a source file produces an error that is impossible to see.

Does my text get uploaded anywhere?

No. The cleaning happens in this tab with plain JavaScript. Nothing is sent to a server and nothing is stored, so closing the page discards whatever you pasted.

Last updated September 19, 2026