How to remove extra spaces from text
You copied a product description from a PDF and pasted it into your store, and got double spaces between words, blank lines in the middle and spaces at the start of lines. The page looks messy, and fixing it by hand takes time.
Where do extra spaces come from?
Copying from a PDF breaks lines and adds spaces. Copying from Word can bring invisible special spaces, like the non-breaking space. Spreadsheets add tabs. They all look like blank space on screen, but to a computer they are different characters, and they can break search or matching.
The rules the tool applies
- Replace special spaces with an ordinary space.
- Trim spaces from the start and end of each line.
- Collapse repeated spaces into one.
- Collapse runs of blank lines into a single blank line, or remove them all.
- Turn tabs into spaces, and remove zero-width characters, both off by default.
Two lines of text with 3 blank lines between them, where the first line, “Welcome to”, starts with two spaces, has 3 spaces between its words and ends with two spaces.
The default rules make 5 changes: trimming the start of one line, trimming the end of one line, collapsing one run of spaces and removing two blank lines.
Result: “Welcome to”, then one blank line, then “our store”.
How to do it
- Open the Whitespace cleaner and paste your text.
- Choose the rules. The number next to each rule shows how many changes it would make.
- Check the preview, and turn on “Show invisible characters” if you want to see spaces and tabs.
- Copy or download the result, or press “Apply to input” to replace your text with it.
What the tool does not change
- It does not change punctuation or diacritics.
- It does not remove hidden direction marks.
- The zero-width option is off by default, because removing those characters can break Persian words or combined emoji.
After cleaning, you can remove repeated lines with the Duplicate-line remover, or compare the text with its original using Text comparison to see what changed.
Common questions
Does my text change right away?
No. You see the preview and the number of changes first, and your text only changes when you press “Apply to input”.
Does it remove a paragraph indent I added on purpose?
Yes, if the trim-start rule is on. Turn it off to keep the indent.
Is my text sent to a server?
No, cleaning happens inside your browser.
