Remove Extra Spaces
Paste your text below, extra spaces and tabs are collapsed and each line is trimmed automatically, as you type.
About the Remove Extra Spaces Tool
Double spaces and stray tabs get collapsed down to a single space, and every line is trimmed of leading and trailing whitespace. It's a quick fix for text pasted from PDFs, spreadsheets, or other formatted sources where spacing rarely comes through clean.
A single, isolated tab character is left completely untouched
The collapsing regex is /[ \t]{2,}/g, which only matches runs of two or more consecutive spaces or tabs. A single lone tab character sitting between two words doesn't meet that threshold, so it passes straight through unchanged — it's neither collapsed to a space nor removed. Two or more tabs in a row, or a mix of spaces and tabs totaling two or more characters, do get collapsed down to one regular space. If your source text uses single tabs as a field separator (common in text copied from a spreadsheet), those tabs will still be sitting in your output exactly as they were.
Non-breaking spaces are only handled at the start and end of a line, not in the middle
The collapse regex's character class, [ \t], matches only the literal space and tab characters, not the non-breaking space (U+00A0) that frequently shows up when text is copied out of a webpage. Multiple non-breaking spaces sitting in the middle of a line won't be collapsed by that step. The per-line .trim() call afterward is more forgiving, since JavaScript's trim() does strip non-breaking spaces and other Unicode whitespace from the very start and end of a string — so a stray non-breaking space at the edge of a line gets removed, but the same character repeated in the middle of a sentence won't be.
Blank-line collapsing keeps one blank line, not zero
With "Also collapse multiple blank lines into one" checked, the pattern /\n{3,}/g looks for three or more consecutive newline characters and reduces them down to exactly two — which is what a single blank line between two paragraphs looks like in terms of raw newlines. A normal single blank line (two newlines) is left completely alone; only runs of two or more blank lines in a row (three or more newlines) get trimmed down to just one. So this option normalizes excessive spacing between paragraphs, it doesn't remove paragraph breaks entirely.
Cleanup happens per line, which is why cross-line spacing isn't touched
Because the text is split into individual lines before any cleanup runs, the space-collapsing step only ever looks within a single line — it has no way to merge or collapse whitespace across a line break, since a newline character isn't part of what [ \t]{2,} matches. That's also why trailing whitespace right before a line break, and leading whitespace at the start of the following line, both get correctly trimmed away independently: each line is processed and trimmed entirely on its own before being rejoined into the final result.
Where inconsistent spacing usually comes from
Text pasted from a PDF frequently carries irregular spacing because PDF text extraction reconstructs word positions from a visual layout rather than from the original source document, and columns, justified paragraphs, or tables often get flattened into runs of spaces standing in for what used to be visual alignment. Spreadsheet cells copied as plain text can bring tabs or padded spaces meant to line up columns visually. And text copied out of a web page sometimes carries non-breaking spaces used by the page's own layout, rather than a normal space character, which is part of why this tool treats non-breaking spaces differently at line edges versus mid-line, as covered above. Running any of that through a quick collapse-and-trim pass before pasting it into an email, a CMS, or a code comment avoids carrying that layout noise along with the actual text.
The character-count stats reflect UTF-16 length, the same measure used elsewhere on the site
Original Chars and Cleaned Chars are both plain .length values, counting UTF-16 code units rather than full Unicode code points — the same convention this site's Line Counter uses for its per-line character counts. For ordinary text this makes no visible difference, but a line containing emoji or other characters outside the Basic Multilingual Plane will show a slightly higher count than the number of characters you'd count by eye.
Frequently Asked Questions
Does this remove single tab characters, not just runs of extra spaces?
No. A single isolated tab is left exactly as it is — the collapsing rule only fires on two or more consecutive spaces or tabs in a row. If you need every tab converted to a space regardless of how many are in a row, this tool's collapsing step alone won't do that for single tabs.
Will this remove non-breaking spaces from the middle of a sentence?
Not from the middle, no. The collapsing regex only recognizes plain spaces and tabs. A non-breaking space at the very start or end of a line does get removed by the trim step, but repeated non-breaking spaces sitting between words in the middle of a line are left untouched.
Does "collapse blank lines" remove paragraph breaks entirely?
No. It only reduces three or more consecutive newlines down to two, which is the equivalent of a single blank line. A normal single blank line between paragraphs is preserved; only excess blank lines beyond that get trimmed.
Can extra spaces spanning across a line break get collapsed together?
No. Cleanup runs on each line independently after the text is split by line breaks, so the space-collapsing step never looks across a newline. Trailing whitespace before a line break and leading whitespace after one are each trimmed separately as part of processing their own line.
Is my text sent to a server when I use this tool?
No. All cleanup happens locally in your browser as you type; nothing is uploaded anywhere.