Remove Extra Spaces
Normalise stray whitespace in pasted text — repeated spaces, tabs, blank lines and characters you cannot see.
What this tool does
Remove Extra Spaces applies a fixed sequence of whitespace rules to pasted text and does nothing else to it. There is no parsing, no reflowing and no correcting of your wording: every line stays in the same order and no line is ever joined to the one below it. The only lines it can take away are blank ones — empty, or holding nothing but spaces and tabs — and inside a line it only ever adds or deletes spacing and invisible formatting characters, never a letter or a digit.
Each rule is a separate switch. Collapse repeated spaces turns any run of two or more spaces or tabs into a single space. Trim spaces at the start and end of each line strips leading and trailing spaces and tabs from every line, indentation included. Blank lines can be left as they are, capped at one in a row, or removed completely. Tabs can be left alone, expanded to between one and twelve spaces, or deleted. Normalising unusual spaces converts the no-break space, the narrow and medium spaces, the ideographic and Ogham spaces and the en-quad-to-hair-space range into ordinary spaces, then deletes zero-width spaces, zero-width joiners, the word joiner, a byte-order mark and soft hyphens.
Fix spacing around punctuation is the one rule that guesses, which is why it is switched off until you ask for it. It removes a space sitting before a comma, full stop, semicolon, colon, question mark, exclamation mark, per cent sign or closing round or square bracket, removes a space just after an opening round or square bracket, adds a single space after a comma, semicolon or colon unless a digit or a slash follows, and adds a space between a sentence-ending mark and the capital letter after it whenever a lowercase letter or a digit sits immediately before that mark. Curly braces are not in that list and are left alone. Web addresses, www-prefixed hosts and email addresses are lifted out before those rules run and put back afterwards so they survive intact. Nothing else is shielded: a bare filename written as report.PDF comes back as report. PDF, and a path such as /var/log/App.Log is split the same way, because the rule cannot tell either from a missing space between two sentences.
The structural limits are worth knowing before you paste. Collapsing and trimming both destroy indentation, so this is the wrong tool for source code, YAML or Python, and a tab-separated table loses its columns wherever two or more tabs sit next to each other. Deleting the zero-width characters is not always harmless either: a multi-person emoji held together by joiners falls apart into its separate figures, and Persian, Arabic or Indic text loses the non-joiner that keeps neighbouring letters from fusing, so that switch belongs off for writing of those kinds. Windows and classic-Mac line endings are converted to plain newlines on the way in, and whatever the settings say, the output always has its leading empty lines and all of its trailing whitespace removed. Other control codes and the Unicode line separators are not in the list above and pass through untouched. All of this happens in this browser tab — the text is not uploaded, and the tool keeps working with the network off — which is also why it is a paste-in, copy-out tool with no file picker and no download.
How to use it
- Paste the untidy text. Drop it into the input box, or press Load sample for a short example carrying double spaces, tabs, trailing spaces and a run of blank lines.
- Check the defaults before you run. Collapse repeated spaces, trim line ends and normalise unusual spaces start switched on, and blank lines start capped at one in a row. Tabs start left alone and the punctuation fix starts off. Turn off trimming when the indentation in your text means something.
- Decide what tabs become. Leave them, convert each one to a set number of spaces, or delete them. The spaces-per-tab box only appears once you choose to convert.
- Run it, then copy the result. The tidied text appears on the right and the summary line counts the characters of stray whitespace removed. The Copy output button hands that version straight to the clipboard.
Processing & privacy
Runs on your device. Your file is processed directly in this browser.
Common use cases
Text copied out of a web page
An HTML copy brings non-breaking and zero-width characters with it. They look like ordinary spaces, but they break searches, sorts and comparisons until they are normalised.
Two spaces after every full stop
Typewriter spacing survives in old documents and in anything typed by someone taught that way. Collapsing repeated spaces brings the whole file to one house style in a single pass.
A code or address that will not match
A single trailing space on a reference, SKU or email address is invisible and defeats an exact-match lookup. Trim spaces at the line ends and the comparison starts working.
Prose lifted from a PDF or a slide deck
Extracted text arrives padded with tabs and ragged leading spaces used for layout. Expanding or deleting the tabs and trimming the lines leaves plain, consistent paragraphs.
Questions
Does the text I paste in leave my browser?
Will it keep the indentation in my code?
Why did my tab-separated columns turn into one?
Why did a space appear inside one of my words?
Which invisible characters does it actually remove?
Can it join wrapped lines back into paragraphs?
Why does my output no longer end with a blank line?
Related tools
- Word Counter — Count words, characters, sentences and reading time.
- Case Converter — Switch between upper, lower, title, camel and snake case.
- Remove Line Breaks — Collapse hard wraps back into flowing paragraphs.
- Sort Lines — Sort lines alphabetically, numerically or randomly.
- Remove Duplicate Lines — Delete repeated lines from a list.
- Find and Replace — Bulk replace text with optional regular expressions.