Remove Extra Spaces

Collapse repeated spaces and tidy punctuation spacing.

Free tool to remove extra spaces from text — collapse repeated spaces, strip spaces before punctuation, trim line ends, or delete every space. Runs entirely in your browser, nothing is uploaded. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is the difference between collapsing and removing all spaces?

Collapsing turns runs of repeated spaces into a single space while keeping word separation. Removing all spaces deletes every space character, which is useful for things like stripping spacing from codes or IDs.

Pasting from PDFs, spreadsheets, or chat apps often leaves double spaces, stray tabs, and awkward spaces before punctuation. This tool cleans all of that in one pass, so copy you reuse looks properly typeset.

How it works

You pick which rules to apply and the tool runs them in sequence over your text:

  • Collapse repeated spaces replaces any run of spaces or tabs with a single space.
  • Remove spaces before punctuation deletes a space sitting directly before , . ; : ? !.
  • Trim line ends removes leading and trailing whitespace from each line while keeping the line breaks.
  • Strip every space deletes all space characters entirely — handy for collapsing a code, ID, or number that should have none.

The rules use simple string replacements, so the result updates instantly as you toggle options or edit the input.

Worked example

Input (paste from a poorly formatted PDF):

Hello    world , this  is   a test .   
  Item 1:   value  ;  Item 2:   value .  

After applying all rules:

Hello world, this is a test.
Item 1: value; Item 2: value.

The collapse rule eliminates the multi-space runs. The before-punctuation rule removes spaces before the commas, semicolons, and periods. The trim rule clears the trailing whitespace on each line.

Where each problem comes from

ProblemTypical sourceFix
Double spacesMicrosoft Word typing habits, OCR outputCollapse repeated spaces
Spaces before punctuationTranslated text, copy-paste from French typographyRemove before punctuation
Trailing whitespaceCode editors, spreadsheet exportsTrim line ends
Spaces in codes or IDsPhone numbers, order IDs copy-pasted with spacesStrip every space

When to combine rules

Most cleanup jobs benefit from collapse + before-punctuation + trim together — this is the “editorial clean” pass that makes pasted content match house style without altering meaning.

Use strip-every-space sparingly. It is right for codes (removing spaces from 1 2 3 4 5 6 7 812345678) but breaks any normal sentence.

Trim is safe to apply always — it only removes invisible trailing characters without touching content.

Edge cases

  • Non-breaking spaces (U+00A0) — used in some languages between a number and its unit — are not the same as regular spaces and are left untouched by the collapse rule. If you see unusual word-spacing after cleaning, you may have non-breaking spaces; use a whitespace-cleaner tool to handle those.
  • Multiple consecutive line breaks — the trim rule does not collapse blank lines between paragraphs. If you want to remove extra blank lines, that is a separate operation.
  • Tabs used for alignment — collapsing all whitespace will break tab-aligned tables in plain text. If preserving tabs matters, use collapse on spaces only.

Everything runs in your browser — nothing is uploaded.