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.

Up to 1 MiB.

Options

For example the no-break space (U+00A0) and the ideographic space (U+3000).

How to use the Remove Extra Spaces

  1. Paste your text. Extra spaces are removed as you type.
  2. 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

Repeated spaces and tabs

Input

  Hello    world.	This  is   a test.  
Second   line.  

Result

Hello world. This is a test.
Second line.
Keep indentation

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.

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.