Whitespace Cleaner
Remove line breaks, extra spaces, and tabs from text.
This tool runs entirely in your browser. Your data is never uploaded, never stored, and never leaves your device.
Cleans text of the invisible mess pasting leaves behind — trailing spaces, stray tabs, runs of blanks and empty lines — and shows the character count before and after so you can see how much went.
How to use it
- 1Paste the text. Trim each line, Collapse multiple spaces and Remove empty lines are already ticked, since those are the safe cleanups.
- 2Tick Remove line breaks to fold the whole thing onto one line, or Remove ALL whitespace to close every gap.
- 3Read the before → after character count, then copy the result.
Example
- Input
- Hello world again
- Output
- Hello world again
Twenty-eight characters in, seventeen out, on the default ticks. The options are not independent: Remove ALL whitespace short-circuits every other one and will run words together, and otherwise the order is fixed — trim, collapse, drop empty lines, then fold line breaks. Collapse multiple spaces matches only spaces and tabs, never newlines, so on its own it cannot join two lines.
What happens to your data
Cleaning is a short chain of regular-expression replacements over the string held in the page's own state, recomputed as you type. Your clipboard is never read — you do the pasting — and the copy button only writes to it when pressed. No version of the text, cleaned or original, exists once the tab is closed.
Last updated August 2026
Text picked up from a PDF, a web page or an email arrives with spacing that was never yours. Lines break where the old column ended rather than where the sentence does, paragraphs carry two blank lines after them, and there are trailing spaces you cannot see until something else complains — a diff marking an unchanged line as changed, a form refusing a value, a spreadsheet cell that will not match its twin.
Before you touch any of the boxes, decide which of two jobs you are doing. The first is tidying: the text should keep its lines, and you only want the ragged edges gone. The second is flattening: the line breaks are an artefact of where the text came from, and you want one continuous run you can drop into a single field. These two pull in opposite directions, and the option that does the second — Remove line breaks — will undo the first if you leave it ticked out of habit.
The mistake worth naming is treating whitespace as decoration. In a Python file, a YAML config, a Markdown draft or anything tab-separated, the spaces and tabs are the structure — collapse them and you have not cleaned the text, you have broken it. Collapsing runs of spaces flattens tabs to single spaces as well, so indented code comes back left-aligned and a tab-separated table comes back as ordinary prose. Clean prose here, and keep the original of anything a machine has to read.
How it works
Toolvore runs the clean-up as a fixed order of regular-expression replacements over the text in the box, recomputed as you type rather than on a button press. Trimming works line by line and matches only spaces and tabs, so it cannot touch a non-breaking space — the character a word processor or a web page leaves behind most often, and the usual reason a line that looks trimmed still refuses to compare equal. Remove ALL whitespace is the exception: it matches the broad whitespace class, so it takes non-breaking spaces, form feeds and every kind of line ending with it. Nothing here removes zero-width characters, which are invisible but are not classed as whitespace at all. Folding line breaks turns a run of newlines into a single space, so paragraph boundaries are lost rather than preserved — there is no setting that keeps one blank line between paragraphs and drops the rest. The counter beside the result compares the two lengths in UTF-16 units, so an emoji counts as two.
Common use cases
- Tidying text pasted out of a PDF before it goes into a CMS field
- Flattening a multi-line address into one line for a form that expects one
- Stripping trailing spaces that make a diff mark unchanged lines as changed
- Closing up the blank lines an email client leaves through a quoted reply
- Turning a column of text copied off a web page into a single paragraph
- Cleaning a list of values copied from a spreadsheet before pasting it into a search box
Frequently asked questions
Why does text copied out of a PDF break in the wrong places?+
A PDF does not store paragraphs. It stores lines placed at fixed positions on a page, and copying reconstructs the text by reading those positions in order, so every visual line ends with a hard break whether or not the sentence did. Two-column layouts make it worse, because the reader may interleave the columns. That is why pasted PDF text usually needs flattening rather than tidying: the line breaks carry no meaning, and folding them into spaces restores continuous prose. Watch for hyphens left at the end of words that were broken across lines — nothing here rejoins those, so you will have to find them yourself.
What is a non-breaking space, and why will it not delete?+
A non-breaking space, U+00A0, looks exactly like an ordinary space but stops a line wrapping at that point. Word processors insert them, and so do web pages, so text pasted from either carries them invisibly. It will delete — the difficulty is that most cleaning steps look for the ordinary space and the tab, and a non-breaking space is neither, so trimming a line and collapsing runs of spaces both step straight over it. Remove ALL whitespace does catch it, because it matches the broader whitespace class, but it closes every other gap in the text at the same time. For one stubborn character, a find-and-replace on that character is more surgical.
Is it safe to strip whitespace from code, JSON or HTML?+
It depends entirely on the language. JSON ignores whitespace between tokens but not inside strings, so a blanket removal turns a valid document into one with corrupted values. HTML collapses runs of whitespace when it renders, except inside pre and textarea elements, where every space is kept exactly. Python and YAML use indentation as syntax, so losing it is not a formatting change but a parse error. Nothing here understands any of that — the replacements run over the whole string with no idea whether a given space sits inside a quoted value or at the start of a block. Use a code formatter for code, and keep whitespace cleaning for prose.
Does my text get uploaded anywhere when I clean it?+
No. The work is done by the page you already have open, in JavaScript, on the text held in the component's own state — there is no request to a server anywhere in the process, and no file is uploaded or downloaded at any point. Nothing is kept between visits either: the box starts empty, and closing the tab takes the text with it. The copy button is the only thing that touches your clipboard, and only when you press it. That matters more than it sounds, because what people paste into a cleaner is often something they were not thinking of as data — a contract clause, a customer list, an internal email.
What counts as whitespace, exactly?+
Narrowly, the space and the tab. Broadly, and this is what a program usually means, the space, tab, line feed, carriage return, form feed and vertical tab, plus a set of Unicode characters that includes the non-breaking space, the en and em spaces used in typesetting, and the ideographic space common in Japanese and Chinese text. Zero-width characters are a separate problem: the zero-width space, the zero-width joiner and the byte order mark are invisible but are not classed as whitespace, so nothing that strips whitespace will remove them. If a string still refuses to compare equal after a clean, one of those is the usual culprit.
Why do two tools give different character counts for the same text?+
Usually one of three reasons. Line endings: a Windows file ends each line with a carriage return and a line feed, two characters, where a Unix file uses one, so the same visible text can differ by the number of lines it has. Trailing newlines at the end of a file are counted by some tools and trimmed by others before counting. And most counts made in a browser are in UTF-16 units rather than characters, so an emoji or a rarer script character counts as two, and a family emoji assembled from several joined pieces counts as far more. Any count is a measure of one encoding, not of what you can see.
What is trailing whitespace, and why does anyone care?+
It is one or more spaces or tabs sitting after the last visible character on a line. You cannot see it, and it survives copying, which is what makes it a nuisance: version control marks a line as changed when nothing you meant to change did, string comparisons fail, and a value pasted into a form is rejected for a reason the error message never explains. One place it is deliberate is Markdown, where exactly two spaces at the end of a line mean a hard line break. Trim a Markdown draft and those disappear, taking your line breaks with them when it renders — worth checking before you clean anything written that way.
How would I do this in an editor or with a regular expression instead?+
Most editors already can. VS Code has a trim trailing whitespace setting that runs on save, and an editorconfig file turns it into a rule everyone on a project shares. For one-off work, a find-and-replace with regular expressions enabled covers most of it: match one or more spaces or tabs before a line ending to trim, match two or more spaces to collapse, match a blank-line pattern to drop empties. On a command line, sed and tr do the same across a whole file at once. The reason to use a page like this instead is text that is on your clipboard rather than in a file.
Used in these workflows
Related tools
Word Frequency Counter
See which words appear most often in your text.
Remove Accents
Strip diacritics from text — turn café into cafe.
Stopwatch & Countdown Timer
A stopwatch with laps and a countdown timer with alarm.
Word & Character Counter
Count words, characters, sentences, and paragraphs in your text.