TheTextCounterTheTextCounter

Remove Extra Spaces

Paste messy text and clean up repeated spaces, blank lines and line breaks instantly, with a count of everything removed.

What to clean

0

Spaces removed

0

Lines removed

0

Characters removed

What does Remove Extra Spaces do?

Text copied from PDFs, emails, web pages and spreadsheets often carries invisible clutter: double spaces after full stops, tabs in the middle of sentences, spaces dangling at the end of lines, and stacks of blank lines between paragraphs. Remove Extra Spaces cleans all of that in one step and tells you exactly how many spaces, lines and characters it removed, so you can see the cleanup rather than trust it.

Cleaner text matters more than it seems. Extra spaces inflate character counts against limits such as an SMS or a meta description, break exact-match searches and comparisons, and produce uneven gaps when text is pasted into a page or a form. Trailing spaces also create noise in version-control diffs.

How to use it

1. Paste your text into the top box.

2. Leave the four options ticked for a full cleanup, or untick any you do not want. The result updates immediately, so you can switch an option on and off to see its effect.

3. Read the three counters under the result: spaces removed, lines removed and characters removed. Press Copy to take the cleaned text with you.

The four options

What each option does, with a real before and after.
OptionWhat it doesBeforeAfter
Collapse repeated spacesReplaces two or more spaces or tabs in a row inside a line with a single spacea b (four spaces)a b
Trim each lineRemoves spaces and tabs at the start and end of every line hello hello
Collapse blank linesTurns any run of blank lines into one blank line and drops blank lines at the very start and endone, three blank lines, twoone, one blank line, two
Unify line breaksConverts every line break style to a single LFa, CRLF, ba, LF, b

A worked example

Take a 65-character input made of seven lines. Line 1 is Hello and world separated by four spaces, with two spaces before and after. Lines 2 to 4 are empty. Line 5 is This is a test. with two to three spaces between the words and around the sentence. Line 6 holds nothing but a tab. Line 7 is Last line, again with extra spaces around and between the words.

With all four options on, the output is three lines of text separated by single blank lines: Hello world, then This is a test., then Last line. The tool reports 24 spaces removed, 2 lines removed and 26 characters removed, so the text shrinks from 65 to 39 characters. Of the three empty lines after the first sentence, two are removed and one stays as the separator; the line that held only a tab becomes the blank separator before Last line, so it is not counted as a removed line.

Why line breaks differ

The three line-break conventions you may meet in pasted text.
NameCharactersWhere you meet it
CRLFCarriage return + line feed (2 characters)Windows files and many email programs
LFLine feed (1 character)macOS, Linux, the web and most code editors
CRCarriage return (1 character)Classic Mac OS and some old exports

Mixed line breaks are invisible but can break scripts, spreadsheets imports and diffs. Leaving Unify line breaks on converts everything to LF. If you switch it off, the tool keeps your text's own line-break style instead of changing it, so cleaning a Windows file never silently turns it into a Unix one.

What it does not touch

The tool never changes words, punctuation or the order of lines, and it keeps single blank lines between paragraphs so your structure survives. A single space between words is always preserved. Spaces inside a line are only collapsed when there are two or more in a row, so intentional single tabs between columns stay as they are.

Non-breaking spaces, which look like spaces on screen but are a different character, are treated as spaces and collapsed or trimmed like the others. That is usually what people want when text arrives from a web page.

When you need this tool

The most common case is text copied from a PDF, where lines break in random places and spaces pile up at the edges. Another is preparing text for an SMS, a meta description or a post with a strict character limit, where every surplus space counts against the limit. A third is lists of names, e-mail addresses or numbers copied from a spreadsheet, where an invisible space at the end of a cell breaks searching, matching and importing.

Cleaning also helps before you compare two texts or paste text into an online form that rejects the input for no visible reason, because the cause is often a space or blank line you cannot see. Paste the text here first and watch the Spaces removed counter: a large number means you have found the culprit.

Privacy

Everything happens in your browser. The text is never sent to a server, stored, or shared, and our analytics tool is told to mask the text boxes on this page.

Frequently asked questions

Will it remove the space between words?

No. Between two words it only ever removes the surplus: four spaces become one, and a single space is left alone.

Why did my text lose its paragraph gaps?

It should not. With Collapse blank lines on, any number of blank lines between paragraphs becomes exactly one. If you see no gap at all, your original text had none, or the paragraphs were separated by spaces only.

What is counted in Spaces removed?

Every space, tab and no-break space that disappeared from the text, not counting line breaks. Line breaks are reported separately in Lines removed, and Characters removed adds everything together.

Can it also delete all line breaks to make one paragraph?

Not at the moment. The tool keeps your line structure and only removes redundancy, because joining lines is a destructive change that is hard to undo when you paste from poems, addresses or lists.

Character Counter →

Share this page

Press Ctrl+D to add this page to your bookmarks.