Whitespace Remover
Strip trailing spaces, blank lines and invisible characters.
Whitespace is only invisible until it breaks something
Spaces, tabs and line breaks are the characters nobody looks at, which is exactly why they cause trouble. A stray space at the end of a line turns a clean pull request into a wall of red and green. Two spaces at the end of a Markdown line silently become a <br>. An extra space in a YAML file shifts a key into the wrong block. A non-breaking space pasted out of a web page looks identical to a normal one but will not match a search, will not split on ' ', and quietly breaks a CSV import. This tool makes all of that visible and then removes it, without sending your text anywhere.
What gets cleaned
- Trailing spaces — the classic. Every line loses whatever spaces and tabs sit at its end. Most editors and linters enforce this; this is the fix for text that never went through one.
- Leading spaces — strips indentation, which is what you want for text lifted out of an email quote or a code block you no longer need indented.
- Repeated spaces — runs of two or more spaces or tabs become a single space. This applies to indentation too, so leave it off when you are cleaning code.
- Blank lines — keep them, collapse runs of them into a single separator, or remove every one.
- Invisible characters — non-breaking space (U+00A0), ideographic space (U+3000), the narrow and thin spaces in the U+2000 block, plus zero-width space, zero-width joiner, soft hyphen and the byte-order mark.
- Tabs — convert them to spaces at the width you choose, or turn leading spaces back into tabs.
- Line endings — normalise to LF or CRLF. Mixed endings inside one file are the usual cause of a diff that claims every line changed.
Text that came out of a PDF or a scan
Copying from a PDF, an OCR pass or an old email produces a particular kind of mess: each line is hard-wrapped at whatever width the page happened to be, so sentences break in the middle and the text will not reflow when you paste it somewhere narrower. There are two ways to undo it, and picking the right one matters.
Blank lines separate paragraphs is the straightforward case — an email, a chat log, a text file that was wrapped at 72 columns. Everything between two blank lines is one paragraph and gets merged.
Detect the print column is for text extracted from a PDF or a scan, where that assumption fails badly: those extractors routinely emit a blank line after every line, so blank lines say nothing at all about paragraphs and the simple mode merges nothing. What does survive the extraction is the print column. Body text fills it — the typesetter is the one who wrapped it — while the last line of a paragraph stops short. So this mode ignores blank lines entirely and ends a paragraph when a line closes with terminal punctuation, or when a line falls well short of the column without ending mid-clause. That last exception matters: a short line ending in a comma was short because the page ran out, not because the paragraph did.
Drop running headers & page numbers belongs with column mode. Page furniture is not merely untidy — the running header lands between the two halves of whatever sentence the page break interrupted, so leaving it in splits a paragraph at every single page turn. The form feed that marks the page break identifies the header; a line carrying one is dropped unless it fills the column or ends mid-clause, either of which means it is the first line of the page rather than furniture.
Rejoin words split by a hyphen handles the other half of the problem — hyphen- at the end of one line and ated at the start of the next becomes hyphenated. It only fires when a lowercase letter sits on both sides of the break, so well- followed by Known and standalone dashes are left alone.
Scanned Chinese, Japanese and Korean text has a problem of its own: OCR frequently inserts a space between every character, turning a heading into 第 一 章. Set spaces inside CJK text to remove them. The first level only closes gaps where a CJK character sits on both sides, which preserves the space you actually want between Chinese and English words. The second level also closes the gaps around Latin letters and digits, which is what fixes headings like 第 1 章. Joining wrapped lines is CJK-aware too — Chinese and Japanese lines are joined with nothing rather than with a space, because those scripts do not separate words that way.
The order the rules run in
Order matters when several options are on at once, so it is fixed and predictable: line endings are normalised first, then invisible characters, then tabs, then CJK spacing, then repeated spaces. Only after that is each line trimmed, hyphens rejoined and wrapped lines merged. Blank-line handling runs last, on the text as it stands by then, followed by the document-level trim. That way "collapse blank lines" sees the lines that became blank after trimming, rather than the ones that merely looked blank because they held three spaces.
How to use it
- Paste your text on the left. The cleaned version appears on the right as you type.
- Start from a preset — Code is conservative, PDF / scanned text turns on joining, de-hyphenation and CJK spacing, Strip everything leaves no optional whitespace standing. Then adjust the individual switches.
- Turn on Reveal to see the result with every remaining space, tab and line break drawn as a visible marker. It is the fastest way to confirm the file is actually clean.
- Copy the result or download it as a
.txtfile.
Frequently asked questions
What exactly counts as an invisible character?
Two groups. Characters that render as a space but are not U+0020 — non-breaking space, ideographic space, en and em spaces, narrow no-break space — are replaced with a normal space so that trimming and collapsing can then reach them. Characters with no width at all — zero-width space, zero-width non-joiner and joiner, word joiner, soft hyphen and the byte-order mark — are deleted outright. Directional marks are deliberately left alone, since removing them would scramble right-to-left text.
Will collapsing repeated spaces destroy my indentation?
Yes, and that is intentional — the rule applies to the whole line so the behaviour stays predictable. If you are cleaning code, use the Code preset, which trims line ends and normalises invisible characters but leaves every other space untouched.
Why did joining wrapped lines merge two separate paragraphs?
In blank-line mode, joining uses blank lines as the only paragraph boundary. If the source separates paragraphs by indentation rather than by a blank line, there is nothing to detect and everything merges — switch to column mode, which does not rely on blank lines at all.
Column mode split a paragraph in the middle. Why?
Because a sentence inside the paragraph happened to end with a full stop exactly at the edge of the print column, which is indistinguishable from a paragraph that ended there. Measured across a full-length book this affects a small fraction of paragraphs, and the failure is a harmless extra paragraph break rather than two paragraphs glued together. There is no signal in the extracted text that separates the two cases.
Can it fix the wrong characters an OCR pass produced?
No. This tool only touches whitespace and invisible characters, so it will close the gaps in 第 一 章 and rejoin broken lines, but a character that was misread as a different character is a different problem and needs a proofread. Dot leaders in a scanned table of contents are also left alone.
Does it handle a large file?
Yes — everything runs on plain string operations, so a file of several megabytes cleans instantly. Only the Reveal view is capped, because drawing a marker for every character in a huge document is what would actually slow your browser down.
Is my text uploaded anywhere?
No. The whole tool is a JavaScript file running in your browser; nothing is transmitted, logged or stored. You can disconnect from the network and it keeps working, which is the honest way to verify a claim like this one.