Remove Extra Spaces

Collapse double spaces and tabs to single spaces and trim each line, while keeping line breaks. Tidy up copied text fast.

Independently verified for accuracy

Calculator by Toolsloft ↗
Output
This text has too much spacing.

Clean up messy spacing by turning any run of spaces or tabs into a single space and trimming the ends of each line. Line breaks stay where they are, so your paragraphs keep their shape while double spaces and stray tabs disappear. It is a fast tidy-up for text pasted from documents or spreadsheets.

How this is calculated

Line endings are normalized to line feeds, then each line has its runs of spaces and tabs collapsed to one space and its leading and trailing spacing removed. Newlines between lines are kept, so only the horizontal whitespace is normalized.

How to use

  1. Paste the text with extra spaces or tabs.
  2. Read the tidied output.
  3. Copy the cleaned text.

Examples

  • Double spaces: a b becomes a b
  • Trimmed line: " hi " becomes "hi"

FAQ

Does it remove line breaks too?
No. Line breaks are preserved. Only spaces and tabs are collapsed and trimmed. To join lines, use the remove line breaks tool.
Are tabs handled?
Yes. Tabs are treated as spacing, so a run of tabs and spaces becomes a single space.

Embed this calculator

Add this free calculator to your own site. Copy the code and paste it where you want it to appear.