Remove Extra Spaces
Clean up text by collapsing extra whitespace, removing line breaks, or trimming.
Why pasted text is full of stray whitespace
Text copied from a PDF, an email client or a web page almost never arrives clean. It carries double spaces, tab characters, line breaks in the middle of sentences, trailing spaces at the end of every line, and invisible characters that survive a visual inspection.
This tool strips all of it in one pass, leaving text you can paste into a document or a CMS without spending ten minutes tidying by hand.
Key takeaways
- PDF copying is the worst offender - it preserves layout line breaks as real ones.
- Double spaces after full stops are a typewriter convention that modern typography does not need.
- Trailing whitespace is invisible but breaks diffs, YAML and Markdown.
- Non-breaking spaces look identical to normal ones but behave differently.
- Zero-width characters can survive copy-paste and silently break searches.
What it cleans
| Operation | Before | After |
|---|---|---|
| Collapse multiple spaces | Hello world | Hello world |
| Remove tabs | Name[tab][tab]Value | Name Value |
| Trim line ends | "text " | "text" |
| Remove blank lines | Line 1, then blank lines, then Line 2 | Line 1 ⏎ Line 2 |
| Join broken lines | a sentence bro[newline]ken up | a sentence broken up |
| Space before punctuation | Hello , world ! | Hello, world! |
The one space or two debate
Double spacing after a full stop is a habit inherited from mechanical typewriters, which used monospaced type where every character occupied the same width. The extra space helped mark sentence boundaries visually.
Proportional fonts - everything you read on a screen or in a printed book - already space sentences correctly. Every current style guide, including Chicago, APA and MLA, specifies a single space. HTML collapses consecutive spaces anyway, so double spaces on the web achieve nothing except inflating your character count.
Invisible characters worth knowing about
| Character | Code | Why it causes trouble |
|---|---|---|
| Non-breaking space | U+00A0 | Looks like a space but does not wrap or match a normal space in search |
| Zero-width space | U+200B | Completely invisible; breaks string matching |
| Zero-width joiner | U+200D | Used in composed emoji; can appear unexpectedly |
| Byte order mark | U+FEFF | Often prefixes files exported from Windows tools |
| Line separator | U+2028 | Breaks JavaScript string literals |
| Ideographic space | U+3000 | A full-width space common in CJK text |
These survive copy-paste and are invisible on screen, which makes them a common cause of "but it looks identical" bugs in spreadsheets, config files and search queries.
Where line breaks matter
- Markdown treats a single line break as a space within a paragraph, and a blank line as a paragraph break. Two trailing spaces force a hard break - which is why removing trailing whitespace can change Markdown output.
- YAML is whitespace-significant and will fail to parse if indentation is altered. Do not run YAML through a generic space cleaner.
- Python uses indentation as syntax, so the same warning applies.
- CSV fields containing line breaks must stay quoted, or the file structure breaks.
- Windows and Unix line endings differ - CRLF versus LF - and mixing them causes spurious changes in version control.
Frequently Asked Questions
How do I remove double spaces from text?
Paste the text into the tool above and it collapses every run of consecutive spaces into a single space in one pass. This is considerably faster and more reliable than a manual find-and-replace, which has to be run repeatedly to catch triple and quadruple spaces.
Why does text copied from a PDF look broken?
Because PDFs store text positioned on a page rather than as flowing paragraphs. Copying preserves the layout line breaks as real line breaks, so sentences arrive chopped up mid-word. Joining broken lines while preserving genuine paragraph breaks fixes it.
Should I use one space or two after a full stop?
One. Double spacing came from monospaced typewriters where every character had the same width. Proportional fonts space sentences correctly on their own, and every current style guide specifies a single space. HTML collapses double spaces anyway.
What is a non-breaking space?
A space character that prevents a line break at that point, written as in HTML. It looks identical to a normal space but is a different character, so text searches and spreadsheet lookups treat the two as non-matching - a very common source of confusion.
Why does my spreadsheet lookup fail on identical-looking text?
Almost always a trailing space or a non-breaking space in one of the cells. The values look the same on screen but are different strings. Cleaning whitespace in both columns resolves this more often than any other fix.
Does removing trailing whitespace affect Markdown?
Yes, in one specific way. Two trailing spaces at the end of a Markdown line force a hard line break. Removing them turns that into a normal soft wrap. If you rely on that syntax, use explicit line-break markup instead.
Is it safe to clean whitespace in code?
Not blindly. YAML and Python treat indentation as syntax, so a generic space cleaner will break them. Trailing whitespace removal is generally safe and often desirable in code, but leading indentation must be preserved.
Is my text uploaded anywhere?
No. Cleaning happens entirely in your browser, so nothing is transmitted or stored. You can safely paste confidential content, and closing the tab discards it.