What This Space Remover Does
This space remover cleans the gaps in your text without touching the words. By default it turns every run of two or more spaces into one, trims the spaces at both ends of each line, turns tabs into spaces and swaps odd Unicode spaces for normal ones. Line breaks stay where they are, so paragraphs and lists keep their shape.
A typical case is a sentence that picked up double spaces while being edited:
Hello world, this is a test.With the default settings it comes out as:
Hello world, this is a test.The line under the result reads 9 removed. If you also want to join lines into one paragraph, run the result through Remove Line Breaks, which handles wrapped text from PDFs and emails.
A Worked Example with the Sample Text
Press Sample to load four lines of messy text. The first line has spaces at both ends and runs of three and four spaces. The second uses tabs between words and a non-breaking space before the word with. After three blank lines, the last line starts with spaces and contains a narrow non-breaking space and an em space.
With the default settings the output is:
This sentence has too many spaces.
It was copied from a spreadsheet with tabs.
A PDF added odd spaces here.The count reads 18 removed. The tabs and the three odd spaces are not part of that number, because each one is replaced by a normal space rather than deleted, so the length does not change. The three blank lines are still there. Turn on Squeeze blank lines and only one blank line is kept, which brings the count to 20 removed.
Remove All Spaces or Remove White Space Completely
Sometimes you want no spaces at all, for example in a phone number, a product code or a key that you need to paste into a form. Set Remove to All spaces and every space is deleted while each line stays on its own row. The line Call 0300 123 4567 or 0300 765 4321 becomes:
Call03001234567or03007654321All whitespace goes further and also deletes tabs and line breaks. That suits a long number that was split across lines. A card test number written as 4111 1111 on one line and 1111 1111 on the next becomes:
4111111111111111Because this mode deletes everything between the words, the trim, tabs, odd spaces and blank line options have nothing left to do, so they are greyed out while it is selected.
A ChatGPT and AI Space Remover for Odd Spaces
Text copied from an AI chat, a PDF or a web page often contains spaces that look normal but are different characters. The usual ones are the non-breaking space, the narrow non-breaking space, thin, en and em spaces, and the wide ideographic space used in Chinese and Japanese text. Find and replace for a double space misses them, and some forms and code editors treat them as letters rather than gaps.
With Fix odd spaces on, each of these becomes a normal space first and is then collapsed with its neighbours. A short list pasted from a chat, with a non-breaking space after the colon, a narrow one after 1. and a thin one inside Drink water, comes out as:
Here are three tips:
1. Sleep early.
2. Drink water.Options Explained
- Trim each line: Both ends is the default. Start only clears leading spaces, End only clears trailing spaces, and Do not trim leaves the edges alone. Any run of spaces at an edge that is not trimmed is still collapsed to one space.
- Treat tabs as spaces: on by default. Each tab is handled like a space, so tabs between words become a single space. Turn it off to keep tabs exactly as they are.
- Fix odd spaces: on by default. Non-breaking, thin, en, em, ideographic and similar Unicode spaces become normal spaces. Turn it off if those characters are there on purpose, such as a non-breaking space that keeps 25 and kg together.
- Squeeze blank lines: off by default. When on, it keeps at most one blank line in a row and drops blank lines at the very start and end.
When a White Space Remover Helps and When It Hurts
It helps with prose, lists, names and values copied between apps: a CV pasted from a PDF, a product description from a supplier's sheet, chat answers you are moving into a document, or a list you plan to clean further with Remove Duplicate Lines or prefix with Add Text to Each Line. Duplicates that differ only by a stray space become exact matches after this step.
Keep it away from text where spacing carries meaning:
- Code and YAML. Leading indentation is trimmed by default and collapsed to one space even with Do not trim, so Python, YAML and nested lists lose their structure.
- Tab-separated data. With Treat tabs as spaces on, the line name, tab, age becomes name age and the columns merge. Turn the option off first.
- Markdown hard line breaks. Two spaces at the end of a line force a line break in Markdown. Trimming the end of the line removes them.
- Aligned plain-text tables. Columns lined up with runs of spaces will shift once the runs are collapsed.
Remove Whitespace in JavaScript or Excel
If you need the same clean-up inside your own code, JavaScript can do it line by line. This keeps line breaks, collapses spaces, tabs and non-breaking spaces, and trims each line:
const clean = text
.split("\n")
.map((line) => line.replace(/[ \t\u00a0]+/g, " ").trim())
.join("\n");Watch out for the shorter text.replace(/\s+/g, " "). In JavaScript \s also matches line breaks, so that one-liner joins all your lines into one.
In Excel, TRIM trims a cell and collapses runs of normal spaces, but it ignores the non-breaking space, character 160, which is common in data copied from web pages. Wrap the cell in SUBSTITUTE(A1, CHAR(160), " ") before TRIM to catch it.
Limits, Line Endings and Privacy
- The engine reads the text in one pass, so the time it takes grows in step with the length of the text. Up to 2,000,000 characters are accepted.
- When you paste or upload text, the page turns Windows CRLF and old Mac CR line endings into LF, so the copied and downloaded result uses LF line endings.
- It changes spaces only. Spelling, punctuation, capital letters and zero width characters are left as they are.
- Your text is processed in your browser and is not uploaded. The Privacy Policy explains what the site does and does not collect.