Extra spaces are the most common dirt in pasted text. Two spaces after every full stop, left over from typing habits. Lines that begin three spaces in, because the source had padding. A gap in the middle of a sentence that is not a space at all but a tab. Text like this looks untidy on the page, and it misbehaves off the page too: a search for a phrase fails when the text holds two spaces where you typed one, and imports and spreadsheets treat the padded version as a different value.

This guide shows how to remove extra spaces with the free Text Cleaner on Ovatly. It focuses on the two cleanups behind the job, space collapsing and line trimming, and on the boundary that makes them safe to use: both work inside lines only. Your line breaks, your paragraphs and your blank lines stay where they were, unless you separately tick a cleanup that touches them.

Contents

  • Quick answer
  • Where extra spaces come from
  • The two cleanups that remove them
  • What space collapsing does not touch
  • How to remove extra spaces, step by step
  • Worked example: one paste, three fixes
  • Limitations and alternatives
  • Common mistakes
  • FAQs
  • Conclusion

Quick answer

Paste your text into the Text Cleaner and tick two cleanups: space collapsing and line trimming. Collapsing reduces every run of spaces and tabs inside a line to a single space, and trimming strips the padding from the start and end of each line. Check the character counts before and after, then copy the result out. Nothing else changes: the words stay in order, the line breaks stay in place, and no cleanup rewords anything.

Where extra spaces come from

Most extra spaces arrive by copying. Text copied from a PDF carries padding at line ends and wide gaps where the page layout spread words apart. Text copied from a web page can bring the spacing of the page's markup with it. Text copied from a spreadsheet or a code editor often contains tabs where you expect spaces, and a tab renders as a gap of unpredictable width, so the same text looks different in every program that opens it.

Some extra spaces are typed. The double space after a full stop is a habit from typewriter teaching that survives in a lot of writing. Indented first lines, pasted from documents that indent paragraphs with spaces instead of settings, add padding at the start of every paragraph. None of these spaces carry meaning. They are layout accidents stored as characters, and they are exactly what collapsing and trimming remove.

The reason to bother is not only tidiness. Exact matching is everywhere in ordinary tools: find and replace, spreadsheet lookups, search boxes, dedupe checks. All of them compare characters literally, and a double space is a different character sequence from a single space. Text with irregular spacing fails matches that look like they should succeed, and the failure is hard to spot on screen.

The two cleanups that remove them

Space collapsing scans each line and reduces every run of spaces and tabs inside the line to a single ordinary space. A three-space gap between words becomes one space. A tab wedged between words becomes one space. The rule is simple and total: inside a line, no gap is wider than one space.

Line trimming handles the ends. It removes the spaces and tabs at the very start of each line and the very end of each line, so no line begins or ends with invisible padding. Together, collapsing and trimming give you text where every gap is exactly one space and every line starts and ends with a visible character.

Both are part of the Text Cleaner's set of six cleanups, alongside blank line removal, HTML stripping (which removes tags only and does not decode entities), quote normalization (which straightens curly quotes and turns the en dash and the em dash into simple hyphens) and zero-width removal (which strips invisible characters). For a pure spacing job you need only the two. Tick more only when the paste has those problems too.

What space collapsing does not touch

The entry states the boundary in one sentence: space collapsing affects spaces and tabs inside lines, never the line breaks themselves. Three consequences follow.

First, paragraphs stay paragraphs. Collapsing will not pull two lines together, and it will not merge a wrapped line back into its sentence. If your text arrived with every line broken mid-sentence, that is a wrapping problem, and joining lines is a different tool's job.

Second, blank lines survive. A stack of empty lines between paragraphs is not made of spaces inside a line, so collapsing leaves it alone. Removing blank line stacks is the separate blank line removal cleanup; tick it as well if your paste has both problems, which pastes from PDFs often do.

Third, single spaces are never removed. Collapsing reduces runs to one space, not to zero. Words stay separated, and text that was already clean comes through unchanged.

How to remove extra spaces, step by step

  1. Paste the text into the Text Cleaner.
  2. Tick space collapsing and line trimming. Add blank line removal if the paste also has stacks of empty lines.
  3. Compare the character counts before and after. The drop is the padding and the extra spaces leaving; for lightly padded text it will be small, and that is fine.
  4. Read a few lines of the result to confirm the spacing looks even, then copy or download the cleaned text.

Worked example: one paste, three fixes

The tool's own documented example shows both cleanups at work. The input is padded: two spaces, the word "Hello", three spaces, the word "world", two more spaces, then four line breaks, then "Next", two spaces, "line". With trim, collapse spaces and remove blank lines ticked, the result is:

Hello world

Next line

Look at what each cleanup did. Trimming removed the two leading spaces and the trailing padding. Collapsing turned the three-space gap between "Hello" and "world" into one space, and the two-space gap in "Next line" into one. The four line breaks became one blank line because blank line removal was also ticked; with only collapsing and trimming ticked, those line breaks would have stayed exactly as they were. The words themselves never changed.

Limitations and alternatives

Collapsing is deliberately blunt. It cannot tell a meaningful wide gap from an accidental one, so text that uses spaces for layout, such as a hand-spaced table or aligned columns pasted as plain text, will lose its alignment. Clean a copy, not the only version, when the spacing might be structural.

It also works one paste at a time, in the browser, which suits documents and messages rather than whole archives. And it only fixes spaces and tabs: irregular spacing caused by non-breaking spaces or other exotic whitespace may need the zero-width removal cleanup as a companion, or a find and replace pass for a specific character.

For problems beyond spacing, neighbouring tools in the Text and Writing Tools archive cover the rest of the cleanup family: rejoining wrapped lines, removing duplicate lines, and find and replace for targeted fixes.

Common mistakes

  • Expecting collapsing to join wrapped lines. It never touches line breaks. Wrapped text needs the lines rejoined first, then cleaned.
  • Cleaning text whose spaces are layout. Hand-aligned columns and spaced tables rely on their spaces. Collapsing flattens them.
  • Forgetting the tabs. A gap that survives a quick visual check is often a tab, not spaces. Collapsing handles tabs inside lines too, which is one reason to use it instead of a manual double-space replace.
  • Skipping the count check. The character counts before and after are the receipt. If the drop is far larger than the padding you expected, look at the result before you use it.
  • Replacing double spaces by hand. A find and replace for two spaces misses triples, tabs and line-end padding, and needs repeating until nothing changes. The cleanup does it in one pass.

FAQs

What counts as an extra space? Any run of two or more spaces or tabs inside a line counts as extra, and so do the spaces padding the start and end of a line. Collapsing reduces each run to one space; trimming removes the end padding entirely.

Will it join my lines or remove line breaks? No. Space collapsing affects spaces and tabs inside lines, never the line breaks themselves. Paragraphs stay separate and wrapped lines stay wrapped.

Does it remove blank lines too? Only if you tick blank line removal, which is a separate cleanup. Space collapsing and line trimming alone leave your blank lines exactly as they are.

Will it change my wording? No. No cleanup rewords anything. Only spacing, blank lines, tags, quote style and invisible characters are touched, and only the ones you tick.

Is my text uploaded? No. Cleaning happens in your browser on your device.

Conclusion

Extra spaces are small, but they are the difference between text that merely looks right and text that behaves right in searches, matches and imports. Two ticks in the Text Cleaner, space collapsing and line trimming, remove them in one pass while leaving every line break and every word untouched. For the full cleanup of text copied from a PDF, including blank lines and invisible characters, see the sibling guide: How to Clean Text Copied From a PDF.