How to use the Remove Extra Spaces
Clean up whitespace in three steps:
1
Paste your text
Paste text with inconsistent spacing, double spaces, tabs, or leading/trailing whitespace into the input area.
2
Select options
Choose any combination of the four options: Trim leading/trailing, Collapse double spaces, Tabs → spaces, and Apply per line.
3
Convert and copy
Click 'Remove Extra Spaces' and copy or download the cleaned output. The stats pills show how many characters were removed.
When to use this tool
Use to fix inconsistent spacing in pasted or exported text:
- →Cleaning text pasted from Microsoft Word or PDF documents that contains double spaces after periods
- →Normalising data before storing in a database where extra leading or trailing spaces cause comparison failures
- →Removing inconsistent spacing from email templates or HTML content before processing
- →Preparing text for string comparison or diff operations where whitespace differences cause false mismatches
- →Cleaning up scraped web content where spacing and tabs are inconsistently applied across elements
- →Fixing form submission data where users accidentally enter extra spaces in name or address fields
Frequently asked questions
Q:What does 'Trim leading/trailing' do?
This removes all whitespace characters (spaces, tabs) from the very beginning and very end of the text. Without 'Apply per line', it only trims the outer edges of the entire document. With 'Apply per line' enabled, it trims the start and end of every individual line, which is more aggressive and useful for normalising list data.
Q:What does 'Collapse double spaces' do exactly?
This replaces any run of two or more consecutive space characters with exactly one space. It does not affect single spaces between words. Tabs are not collapsed unless you also enable 'Tabs → spaces', which converts tabs to spaces first and then lets 'Collapse double spaces' catch any resulting runs.
Q:What does 'Apply per line' change?
Without 'Apply per line', the trim and collapse operations are applied to the text as a whole — only the very start and end of the entire document are trimmed. With 'Apply per line' enabled, each individual line is processed independently: its leading and trailing whitespace is trimmed, tabs are replaced, and consecutive spaces within it are collapsed. This is the appropriate mode for cleaning tabular or list data.
Q:Does it affect spaces inside quoted strings?
The tool processes all text uniformly as plain text — it has no awareness of string literals, quotation marks, or code syntax. If you have intentional double spaces inside quoted strings or code that should be preserved, you should process the text in targeted sections rather than applying the tool to the entire document at once.
Q:Why does my text from Word have double spaces?
The typographic convention of placing two spaces after a period at the end of a sentence was common practice through the typewriter era and persisted in word processors. Microsoft Word's default autocorrect settings sometimes also introduce inconsistent spacing. This tool's 'Collapse double spaces' option removes all such double spaces in one click, normalising the text to modern single-space convention.
Q:Can I use this to normalise whitespace before a regex or string comparison?
Yes — this is one of the most common programmatic use cases. Normalising whitespace before comparing strings eliminates false mismatches caused purely by spacing differences. Enable all four options together for the most aggressive normalisation: trim edges, collapse spaces, convert tabs, and apply per line. The output will have maximally consistent, minimal whitespace.