What Remove Extra Spaces does, and when you need it
Remove Extra Spaces tidies the spaces in a text. It makes every run of two or more spaces one space, takes the spaces off the start and end of each line, turns tabs into spaces, and can take out empty lines. The tidy text appears in the second box as you paste, ready to copy or download, with a line that says how many characters went. The box with your own text is never changed.
Each of the four jobs has its own tick box, so you choose what changes. Words, letters and line breaks are never touched: only spaces, tabs and, if you ask, empty lines. It runs in your browser: your text is never uploaded and never saved, so closing the page forgets it.
Some jobs it is made for:
- Text copied from a PDF or a web page, which often comes with double spaces, spaces at the ends of lines and strange invisible spaces.
- Form answers and addresses, where a stray space makes two copies of the same name look different.
- Lists from a spreadsheet, whose cells carry spaces at their ends.
- A letter or an essay typed with two spaces after each full stop, for a form that wants one.
- Before other tools: sorting, removing repeats or comparing work better on tidy lines.
Step by step: tidying the spaces
It takes a few seconds, and the same steps work on a phone and on a computer:
- Put your text in the top box. Paste it with the Paste button, with Ctrl+V, or by pressing and holding in the box on a phone. You can also type it, choose Open a text file, or drop a text file anywhere on the page. Press Try a sample to see it work first.
- Choose what to tidy. Three boxes are ticked at first: Make runs of spaces one space, Remove spaces at the start and end of lines, and Turn tabs into spaces. Remove empty lines is not ticked, so paragraphs stay apart.
- Read the line under the result. It says how many characters went, for example "12 characters removed."
- Copy or download the result. Copy puts the whole tidy text on your clipboard; Download saves it as a text file.
Press Try a sample: the box gets two lines with too many spaces and a tab, and two empty lines between them. The result is This line has too many spaces., the two empty lines, and And this one has a tab., and the page says 12 characters removed. Tick Remove empty lines and the two empty lines go too, leaving two lines.
Which spaces go, exactly
The tool works on each line in turn, in the order below, and then puts the lines back together. The rules are written here in full, and the same rules are checked by our tests.
| Part | The rule | Example |
|---|---|---|
| Turn tabs into spaces | On at first: each tab becomes one space, before anything else is done | Kumar, two tabs, Class becomes Kumar Class with the next rule |
| Make runs of spaces one space | On at first: two or more spaces in a row become one ordinary space. Besides the ordinary space, this counts the no-break space, the narrow no-break space, the ideographic space of Chinese and Japanese text and the other typographic spaces | a b becomes a b |
| One space alone | A single space of any kind stays as it is, a no-break space included | ₹ 500 with one no-break space keeps it |
| Remove spaces at the start and end of lines | On at first: every kind of space and tab at the two ends of each line goes | keep becomes keep |
| Remove empty lines | Off at first. On, lines with nothing in them, or only spaces, go | one, two empty lines, two becomes one, two |
| The count | The note says how many characters the text lost: a tab turned into a space is not counted, since the length is the same | The sample: 12 characters removed |
| Untouched | Letters, punctuation and line breaks. Tabs stay when Turn tabs into spaces is off | x, two tabs, y with tabs off stays as it was |
With all four boxes ticked, Name:, two no-break spaces, Ravi Kumar, two tabs and Class: 10 becomes Name: Ravi Kumar Class: 10, 4 characters shorter.
Real results from our tests
We tested Remove Extra Spaces with headless Chromium 148, the open-source browser Chrome is built on, on a Windows laptop with an Intel Core i7-1185G7 and 32 GB of memory, on 1 November 2026. Other work was running on the laptop at the same time, so times vary from run to run: each time below is the middle one of 3 runs.
Tidying is quick. It took 23 milliseconds or less to tidy 500,000 characters of English full of runs of spaces, tabs and spaces at the ends of lines, with all four boxes ticked, the most the page takes at once.
After a text is put in the box, the page waits 0.15 second before it works, so a burst of typing is worked on once, and 0.4 second when the text has more than 400,000 characters. So the result of 500,000 characters of English showed between 0.47 and 0.54 second after it was put in the box in our test. A result of more than 100,000 characters shows only its first 100,000 in the box, and says so, because showing a very long text is slow for the browser; Copy and Download take all of it.
Checked by our tests. Every example on this page is one of our tests, run on the page's own code. They cover runs of ordinary spaces, no-break spaces and the ideographic space, a single no-break space that stays, tabs with the box on and off, spaces at the ends of lines, empty lines, and the count of characters removed.
Size and offline. On a first visit the page downloads about 0.1 MB for the tool: the page, its styles, its scripts and the fonts, with Google's ad code not counted. In our test we switched the network off after the page had loaded and pressed Try a sample: the result showed 0.2 seconds later or less in each of 15 runs.
Phone-sized screen. We also ran the tests on a phone-sized screen in headless Chromium (390 × 844 pixels, with touch). That is not a real phone. Every button, box and tick box was 44 pixels high or more, and the page did not scroll sideways. These tests don't cover Safari or Firefox.
Try it yourself: press "Try a sample" at the top of this page. It puts two lines in the box with too many spaces, a tab and two empty lines between them. The result is This line has too many spaces. and And this one has a tab., and the page says 12 characters removed. Then tick Remove empty lines.
Try the sampleWhere extra spaces come from
Knowing where they come from helps you decide which boxes to tick:
- Two spaces after a full stop. Typists were once taught this. Make runs of spaces one space fixes it everywhere at once.
- Text from a PDF. A PDF places words by position, so copied text may have runs of spaces where columns were, and spaces at the ends of lines. Tick the first three boxes. For lines broken in the middle of sentences, use Remove Line Breaks afterwards.
- Spreadsheet cells. Cells often carry a space at their end, and a column copied out of a sheet comes with tabs between the cells. Turn tabs into spaces makes them spaces; untick it if you want to keep the columns.
- Lines lined up with spaces. Text aligned by hand with many spaces loses its alignment when the runs become one space. If the alignment matters, untick Make runs of spaces one space.
- Pasted form answers. A name typed with a space at the start sorts and matches badly. Remove spaces at the start and end of lines cleans every line of a list at once.
Everyday uses
- Before removing repeats.
New DelhiandNew Delhiare different lines until the spaces are tidied. Tidy here, then use Remove Duplicate Lines. - Before sorting. A line that starts with a space sorts first. Tidy here, then use Sort Lines.
- Before counting. Extra spaces don't change a word count, but they do change a character count with spaces: tidy first if a form counts characters.
- Before comparing two versions. Spaces make lines differ in Text Compare; tidy both first to see only the real changes.
- For a form with a character limit, where every stray space counts against you.
Opening a text file
Choose Open a text file, or drop a file anywhere on the page, and the tool reads it on your device. These files open: .txt, .md, .csv, .tsv, .log, .json, .xml, .srt, .vtt, .html and other plain-text files, with up to 500,000 characters. The file's name and size appear below the box with an x; press the x to remove the file's text. The file is read on your device and never uploaded. The result can be copied, or saved as a new text file; the file you opened is never changed.
- Letters. A file saved as UTF-8 (a byte order mark at the start is dropped) or as UTF-16 with a mark is read correctly, Hindi and Tamil included. A file that is not valid UTF-8 is read as Windows-1252, and the page says so: "This file isn't saved as UTF-8, so it was read as Windows-1252. If letters look wrong, save it as UTF-8 and add it again."
- Windows line breaks. A Windows file stores each line break as two characters. The tool reads the pair as one line break, so the lines of a Windows file are tidied one by one like any other.
- Several files. Only the first one opens, and the page says so, for example "Opening a.txt only. Open the others one at a time."
- Not a text file. A Word, PDF or picture file renamed to .txt is not read, and the page says it doesn't look like a text file. A file named .docx, .pdf or .rtf gets this message: "Only text files (.txt and similar) can be opened here. For a Word or PDF file, copy its text and paste it into the box."
- Empty or too long. An empty file says it is empty. A file with more than 500,000 characters is not opened, and the page says how many characters it has.
For a Word or PDF file, open it in the program you normally use, select the text, copy it, and paste it into the box. A PDF whose pages are scans holds pictures, not text, so there is nothing to copy.
Private: your text stays on your device
Your text never leaves your device. The tool runs inside your browser and has no upload step: it never sends the text you type, paste or open anywhere, and it keeps no copy of it, so closing the page forgets it. The page's Content Security Policy lets it contact only this site and Google's ad service, which pays for the site; our code never gives your text to the ad code. You can check it yourself in your browser's network panel (F12 on a computer): removing the spaces adds no request that carries your text. The site's menu does remember the last few tools you opened, on your device.
Text that needs tidying is often personal: a form's answers, an address, a letter or notes copied from a document. This tool lets you clean it without handing it over. Our privacy policy says what we collect, and How we prove it shows how you can check our claims yourself.
Once the page has loaded, it also works with the internet switched off. In our test we switched the network off after the page had loaded and pressed Try a sample, and the result showed 0.2 seconds later or less in each of 15 runs.
Long texts
The tool takes up to 500,000 characters at once, about 500 KB of English text. What happens when a text is longer:
- A paste that would go over the limit is not added. This holds for Ctrl+V, for press and hold, and for the Paste button. The page says, for example: "That text is very long (550,000 characters), so it was not added. The box can hold 500,000 characters. Split it into smaller parts for faster results."
- A file with too many characters is not opened. The page says, for example: "long.txt has 550,000 characters, more than the 500,000 counted at once. Split it into smaller parts for faster results."
- A text that gets in some other way stays, unchanged. If text is dragged into the box, for example, it stays there, the result stays empty and the note says: "This text is very long (550,000 characters). Split it into smaller parts for faster results."
Tidying is quick. In our tests it took 23 milliseconds or less to tidy 500,000 characters of English full of runs of spaces, tabs and spaces at the ends of lines, with all four boxes ticked. The slow part is the browser showing a very long text in a box, so a result of more than 100,000 characters shows only its first 100,000, without cutting an emoji in half, and the note says so, for example "Showing the first 100,000 of 164,999 characters. Copy and Download take all of it." Copy and Download always take the whole result.
Tips
- Leave Remove empty lines off for letters and essays, so paragraphs stay apart. Tick it for lists.
- Untick Turn tabs into spaces for data copied from a spreadsheet, if you want to paste it back into columns.
- Untick Make runs of spaces one space for text lined up in columns with spaces.
- Tidy first, then sort, count or compare: the other tools work better on clean lines.
- Check the count. If the note says 0 characters removed, the text had no extra spaces of the kinds this tool looks for.
- Keep your own copy. The page forgets everything when you close it.
Limits
- Spaces and tabs only. It doesn't fix line breaks in the middle of sentences (use Remove Line Breaks), spelling or capital letters.
- Zero-width characters stay. The zero-width space and the soft hyphen are not spaces, and are left in.
- Alignment is lost when runs of spaces become one. Untick that box for aligned text.
- No space is added. Words written together, such as
NewDelhi, stay together. - 500,000 characters at once, about 500 KB of English text.
- Text only. It doesn't open Word or PDF files: copy their text first.
Terms explained
- Whitespace
- Spaces, tabs and line breaks: characters that show as empty room rather than as a mark.
- No-break space
- A space that keeps the words on either side of it on the same line.
- Tab
- The character the Tab key types, used to line text up in columns.
- Trim
- To take the spaces off the start and end of a line.
- Leading and trailing spaces
- Spaces at the start and at the end of a line.
- Zero-width space
- An invisible character that marks where a line may break. It takes no room and is not removed here.