Remove Extra Spaces
Cleans up spacing by trimming the start and end of lines and turning runs of spaces and tabs into single spaces. Use it to fix text pasted from PDFs or documents, or to tidy up copy before it goes into a form, spreadsheet or web page.
How to use the Remove Extra Spaces
- Paste your text. Extra spaces are removed as you type.
- Choose whether to trim the start and end of lines, collapse repeated spaces and tabs, and include no-break and other Unicode spaces.
Rules applied
- Line breaks and empty lines are never removed. To remove those use Remove Empty Lines or Remove Line Breaks.
- Tabs become single spaces when collapsing is on.
- The status line shows how many characters were removed.
Limitations
- Indentation at the start of lines is removed when trimming is on; turn it off for code.
- Zero-width spaces are not spaces; remove them with the Invisible Character Remover.
Worked examples
Input
Hello world. This is a test. Second line.
Result
Hello world. This is a test. Second line.
Input
indented line
Result
indented line
Practical uses
-
Fixing text copied from a PDF
An office worker pastes text from a PDF that has double spaces and stray tabs between words. They leave collapsing and trimming on and the tool cleans the text in one pass. The result has single spaces and tidy line ends, and the status line shows how many characters were removed.
-
Cleaning a spreadsheet column
A bookkeeper pastes a column of names with spaces at the end, which stops lookups from matching. They keep trimming on and the trailing spaces disappear. The names can then be imported and matched without errors.
-
Preserving code indentation
A developer wants to tidy repeated spaces inside a code snippet without moving its layout. They turn off trimming so the indentation at the start of each line stays in place. The extra spaces within the lines are still collapsed.
Related tools
Privacy: this tool runs entirely in your browser. Your text is not uploaded, logged or saved, and it is never sent to analytics. Maximum input: 1 MiB.