Whitespace Remover

Four independent cleanups: collapse spaces, trim line ends, drop blank lines, unwrap paragraphs.

Cleaned
—

Worked example

Text copied from a PDF usually contains non-breaking spaces (U+00A0) that look identical to normal spaces and break every search and regex. Converting them is the fix that most people miss.

Whitespace problems are invisible until something downstream breaks: a search that should match does not, a CSV column shifts, a diff shows every line changed. The characters involved are usually not the ones you think.

The four invisible characters

Non-breaking space (U+00A0) from web pages and PDFs, zero-width space (U+200B) from some editors, the tab, and the carriage return. Only the last two are obvious. The first two look exactly like a normal space and silently defeat string comparison.

Unwrapping

Hard-wrapped text — from an email, a PDF column, or an editor set to 72 columns — has newlines that are not paragraph breaks. Unwrapping joins them within each paragraph while preserving blank-line boundaries, which is the only reliable signal for a real paragraph break.

Order matters

Converting non-breaking spaces happens first, then unwrapping, then trimming and collapsing. Reversing that order leaves stray characters inside joined lines that no later step will catch.