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
| Problem | Typical source | Fix |
|---|---|---|
| Double spaces | Microsoft Word typing habits, OCR output | Collapse repeated spaces |
| Spaces before punctuation | Translated text, copy-paste from French typography | Remove before punctuation |
| Trailing whitespace | Code editors, spreadsheet exports | Trim line ends |
| Spaces in codes or IDs | Phone numbers, order IDs copy-pasted with spaces | Strip 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 8 → 12345678) 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.