Remove Extra Spaces Online
Paste text that has picked up stray whitespace and watch it clean up as you type. Doubled and tripled spaces collapse to one, spaces clinging to the start and end of a line are trimmed, tabs become the number of spaces you choose, blank lines can go, and the non-breaking and zero-width spaces that come home from a PDF, a web page or a chat app are normalised into ordinary ones. A running summary counts exactly what changed, so you can see the tool did something before you copy it. It never joins your lines and never rewrites your words. This is whitespace cleanup, not editing. Everything runs in your browser: nothing is uploaded, and there is no account, no API and no length limit but your own device.
Quarterly review becomes Quarterlyreview. Line breaks, letters, digits and punctuation are untouched. It is the right tool for a column of product codes, a list of identifiers or a string that has to be compact, and the wrong tool for anything meant to be read. Switch back to Clean whitespace at any time; nothing is lost, because the result is recalculated from your input on every change.
Paste some text and the changes will be counted here.
Your text stays in your browser. Nothing is uploaded.
How to Remove Extra Spaces from Text
Paste the text into the box on the left. The cleaned version appears on the right immediately. There is no button to press and nothing to submit, so what you see updates on every keystroke and every option you change. When the result looks right, press Copy Output and paste it wherever it was going.
The defaults are chosen for ordinary prose: runs of spaces collapse to one, whitespace at the start and end of each line is trimmed, tabs become a single space, and unusual space characters are normalised. Blank lines are kept, spacing around punctuation is left alone, and your indentation is preserved only if you ask for it. Every option is independent, so you can switch off anything that does not suit the text in front of you and see the effect straight away.
Under the options, the What changed panel counts the work: characters removed, spaces removed, tabs converted, invisible spaces normalised, lines removed. Rows that would read zero are not shown at all. If your text was already clean the panel says No extra spaces found rather than pretending to have done something.
Press Load Example first if you would like to see the tool work on a deliberately messy paragraph. It contains doubled and tripled spaces, trailing spaces, a tab-indented row, two blank lines, spaces before punctuation, two non-breaking spaces and a zero-width space, alongside a 1 : 3 ratio that survives untouched to show what the punctuation rule refuses to change.
What Causes Extra Spaces in Text?
Almost nobody types three spaces between two words on purpose. The whitespace arrives from somewhere else, and knowing where it came from tells you which options to switch on.
Copying from PDFs
A PDF stores text as positioned glyphs, not as a paragraph. When you select and copy, the reader reconstructs the words from their coordinates and guesses at the gaps. Justified text is the worst case: the renderer stretched the word gaps to make the right-hand edge line up, and the copy carries that stretch with it, so a single sentence can contain gaps of two, three or four spaces. Line ends often pick up a trailing space, and hyphenated words may arrive split across a line break. Non-breaking spaces are common too, because the PDF used them to keep a number attached to its unit.
Copying from websites
HTML collapses whitespace when it renders, so the source can contain any amount of indentation and line wrapping without changing what you see. Copying takes the rendered text but not always cleanly: template engines leave non-breaking spaces where a designer wanted to prevent a wrap, icon fonts leave zero-width artefacts, and content management systems frequently insert a byte-order mark (U+FEFF) at the start of a field. A space that looks ordinary and refuses to delete is usually one of these.
Word processors and email
Word and Outlook normalise some whitespace and preserve other kinds, and pasting between them and a plain-text field is where the mismatch shows. Two full stops become one, a double space after a full stop survives or does not depending on the version, and the automatic bullet and numbering features insert tabs that only make sense inside that document. Quoted email text adds a leading > and often a trailing space on every line.
ChatGPT and AI-generated text
Language models emit Markdown, and Markdown uses whitespace structurally: two trailing spaces mean a hard line break, four leading spaces mean a code block, and a blank line separates paragraphs. Pasted into a plain text box, those conventions become stray trailing spaces and unexplained indentation. Models also frequently use non-breaking spaces inside numbers and units — 12 kg, EUR 500 — which look right on screen and break a search or a sort afterwards. ChatGPT Text Cleaner handles the Markdown and the hedging; this page handles the whitespace left behind.
Manual editing and tabs
The most common source is simply editing. A sentence gets rewritten and the old spaces stay; a column gets aligned by hand with the space bar; someone holds down a key. Tabs are a category of their own, because one tab can display as two, four or eight spaces depending on the viewer, so a file that looks aligned on one screen looks ragged on the next. Converting tabs to a fixed number of spaces removes that ambiguity, which is why the option is here.
How to Remove Double Spaces
Switch on Collapse multiple spaces, which is on by default. Every run of two or more spaces becomes exactly one, so This is a test becomes This is a test. A single space between two words is never touched, which is what makes the rule safe: it shortens runs, it does not remove word separation.
Two details matter more than they look. First, the collapse happens after tabs are converted and unusual spaces are normalised, so a gap made of one space plus one non-breaking space plus one tab is still recognised as a run and still collapses to a single space. If it ran the other way round, mixed whitespace would survive, which is exactly the case people paste from PDFs and web pages. Second, the collapse is per line and never crosses a line break, so your paragraph structure is untouched. This tool does not join lines.
There is one legitimate double space that some writers will miss: the traditional two spaces after a full stop. Modern style guides — APA, Chicago, Microsoft, Google — all ask for a single space, and the web collapses a double space to a single one when it renders anyway, so the second space is invisible in a browser whatever you do. If you genuinely want to keep it, switch the collapse option off and use Find & Replace Text to target the specific pattern instead, which gives you control this page deliberately does not.
Remove Leading and Trailing Spaces
Switch on Remove leading & trailing spaces, also on by default. Spaces before the first character and after the last character of each line are deleted. Trailing whitespace is invisible in almost every viewer and causes a surprising amount of trouble: it makes two identical-looking lines unequal to a computer, so a sort puts them in an arbitrary order and a duplicate check misses them; it breaks exact-match lookups in spreadsheets and databases; in Markdown it silently means “hard line break”; and in code, linters flag it and diff tools show it as a change to a line you never edited.
Leading whitespace is a different question, because sometimes it is the formatting. That is what Preserve indentation is for, described in the next section. With preservation off, leading spaces are treated as noise and removed, which is what you want for prose pasted from a PDF or an email where every line picked up the same accidental margin.
Both operations are per line. The start and end of the whole document are covered because the first and last lines are lines too, so a stray newline of spaces at the top or bottom of a paste goes as well.
Remove Extra Whitespace Without Destroying Formatting
Whitespace cleanup is only useful if it does not flatten the thing you were cleaning. Three options on this page exist purely to protect structure.
Preserve indentation keeps the leading run of spaces and tabs on every line exactly as it is — neither collapsed nor trimmed — while still cleaning everything after it. So a block of Python keeps its four-space levels and still loses the doubled spaces inside the code, and a nested list keeps its depth while the text of each bullet tightens up. This matters for code, for lists, for poetry, for tables aligned by hand, for ASCII diagrams and for anything where the left-hand edge carries meaning. It is off by default because most pastes are prose and prose has no indentation to preserve; switch it on the moment the text has a shape.
Leave tabs alone does the same job for a file that is meant to stay tab-indented, such as a tab-separated export or code in a tab-indented style. With it selected, tabs pass through untouched and the other rules work around them. Choosing 2, 4 or 8 spaces instead converts every tab consistently, which is how you make a file that looks the same everywhere.
Remove spaces before punctuation is off by default for the same reason. It fixes an obvious accident — Hello , world ! — but spacing around punctuation is a style choice in some languages and some documents, so the tool will not make it for you unless you ask.
If you are cleaning something where a mistake is expensive, run it twice: once with the options you want, then paste the result into Text Compare & Diff against the original and read the differences. That is a two-second check and it shows you exactly what moved.
Remove Invisible and Non-Breaking Spaces
This is the option that solves the problem people cannot diagnose. You can see a space, you select it, you press backspace, and either nothing happens or the wrong character disappears. The reason is that the character is not a space — it only looks like one.
Unicode contains a family of characters whose job is to occupy horizontal space. The best known is the non-breaking space U+00A0, which HTML writes as and which a browser inserts to stop a line breaking between a number and its unit. There are also en and em spaces, a thin space, a hair space, a narrow non-breaking space U+202F, a medium mathematical space U+205F, the ideographic space U+3000 used in Chinese, Japanese and Korean text, and the Ogham space mark U+1680. They all render as a gap. None of them is U+0020, so a rule that looks for two spaces in a row walks straight past them.
Alongside those are the zero-width characters, which occupy no space at all and are therefore completely invisible: the byte-order mark U+FEFF, which turns up at the start of fields exported from content management systems and spreadsheets, and the zero-width space U+200B, left behind by editors, wikis and chat apps. These do not look wrong, but they break exact-match searches, they change character counts, they make two visually identical strings unequal, and they can silently corrupt an identifier or a URL.
With Normalize invisible spaces on, the width-bearing characters become ordinary spaces — so the gap still looks the same to a reader, but the collapse and trim rules can now see it and act on it — and the zero-width artefacts U+FEFF and U+200B are deleted outright. The What changed panel counts how many were found, which is often the first time anyone has known they were there.
Three zero-width characters are deliberately never touched, because removing them would damage ordinary text. U+200D, the zero-width joiner, is what holds an emoji family together: the sequence behind 👨👩👧👦 is four people joined by three of them, and stripping the joiners turns one picture into four. The same character forms conjuncts in Devanagari and other Indic scripts. U+200C, the zero-width non-joiner, changes the shape of letters in Persian, Arabic, Urdu and several Indic languages, so removing it changes what the word says. U+2060, the word joiner, controls line breaking. None of the three is a space in any sense a reader would recognise, and a whitespace cleaner that eats them is a bug, not a feature.
So the honest summary is this: this tool normalises the whitespace that behaves like whitespace, deletes the artefacts that behave like nothing, and leaves the joiners that carry meaning completely alone. If you specifically need a zero-width joiner gone, that is a deliberate edit and Find & Replace Text is the right place to make it.
What This Tool Deliberately Leaves Alone
A cleaner that changes too much is worse than no cleaner, because you cannot trust the result. These are the rules this page follows, and they are the reason the defaults are what they are.
Your words are never rewritten. No option here changes a letter, a digit, a word order, a capital or a spelling. The only characters this tool deletes are whitespace characters. 1984 was a great year comes back as 1984 was a great year; 3 blind mice comes back unchanged; a number, a date, a code or a year at the start of a line is never mistaken for something to clean.
Lines are never joined. The line count can only ever go down, and only if you switch on Remove blank lines. A paragraph stays a paragraph. Joining wrapped lines is a different job with different risks and it lives at Remove Line Breaks.
A digit on both sides of a punctuation mark is left exactly as written. With Remove spaces before punctuation switched on, Hello , world ! becomes Hello, world!, while 1 : 2, 12 : 30 and 3 . 14 stay as they are, because a digit either side of a colon, a full stop or a comma is usually a ratio, a time, a score or a decimal written the European way, not a typing mistake. This is a deliberate false negative: it is better to leave one accidental space than to quietly rewrite a number.
Only six punctuation marks are affected, and only when you ask: the full stop, comma, exclamation mark, question mark, colon and semicolon. Brackets, quotation marks, slashes, dashes and apostrophes are never repositioned, and French and Swiss typography — which puts a space before ! ? : and ; on purpose — is safe as long as you leave the option off.
Unicode text is not altered. Accented letters, right-to-left scripts, Chinese, Japanese and Korean, combining marks and emoji all pass through byte for byte. Character counts are UTF-16 code units, the way a browser’s textarea counts them, which means an emoji outside the Basic Multilingual Plane reads as two. If you are checking a cleaned block against a hard limit, Character Counter counts the result accurately, and Word Counter will tell you what the cleanup did to the word count.
Remove Extra Spaces vs Remove Line Breaks
These two sound alike and do different jobs. Picking the wrong one is the most common mistake people make with whitespace, so it is worth being precise.
Remove Extra Spaces works within each line. It shortens runs of spaces, trims the ends of lines, converts tabs, normalises invisible characters and can drop blank rows. It never joins two lines together and it never reflows a paragraph. Your text has the same shape afterwards, only tighter. If the problem is that a paste looks ragged, has stray gaps, contains spaces that will not delete, or has to match another string exactly, this is the page.
Remove Line Breaks works between lines. Its job is to take text that was wrapped — by a PDF page, an email client, a fixed-width column or a hard return at the end of every sentence — and join it back into flowing paragraphs. It groups lines, decides where a paragraph genuinely ends, and re-emits the text as prose. That is a structural change, and it is the right one when a paste has a line break in the middle of every sentence.
The overlap is small and honest: both pages can remove blank lines, because a blank line is whitespace. Neither will do the other’s main job. A useful sequence when a PDF paste is badly broken is to run it through Remove Line Breaks first to restore the paragraphs, then through this page to tighten the spacing inside them, then Remove Duplicate Lines if the extraction repeated a header or a footer on every page.
Common Uses for an Extra Spaces Remover
Cleaning text copied from a PDF
The most common reason people search for this. Switch on collapse, trim and invisible-space normalisation; leave Remove blank lines off until you have checked that the blank lines are not paragraph breaks. If the copy also has a line break at the end of every visual line, run Remove Line Breaks first.
Cleaning ChatGPT and AI output
Models emit Markdown and non-breaking spaces. Collapse and normalisation remove the residue; AI Text Cleaner and ChatGPT Text Cleaner handle the filler and the formatting marks themselves, and Grammar & Style Cleaner deals with what is left.
Preparing text for a document or a publish
Trailing spaces and doubled gaps are invisible right up to the moment a layout engine renders them. Cleaning before you paste into a CMS, an email or a manuscript means the formatting you see is the formatting you get.
Preparing CSV and other data
A space around a delimiter is the classic cause of a lookup that silently fails: ABC123 does not equal ABC123. Trim and normalisation make the values match. Do not use Remove all spaces on a CSV row unless you mean to destroy the delimiters; it removes every space including the ones inside quoted fields.
Cleaning lists
Paste a list, trim it, then Text Sorter & Alphabetizer to put it in order and Remove Duplicate Lines to drop the repeats. Cleaning first matters: an untrimmed list sorts wrongly and hides duplicates, because the extra space makes two identical entries different.
Removing accidental double spaces
The one-line fix. Collapse is on by default, so pasting and copying is the whole job.
Codes, identifiers and compact strings
This is what Remove all spaces is for: a column of product codes, a list of SKU values, a phone number split over a line, a hashtag that picked up a gap. It is a separate mode rather than a checkbox precisely so that nobody switches it on while cleaning prose.
Checking that a cleanup was safe
Paste the original and the cleaned text into Text Compare & Diff and read the differences before you commit to them. For anything numbered, Add Line Numbers to Text on both sides makes the comparison line by line.
Filling a layout to test it
The opposite job, but a related one: Lorem Ipsum Generator produces clean placeholder text, so if your design breaks with real pasted content and not with Lorem Ipsum, the difference is usually the whitespace.
Remove Extra Spaces Without Uploading Your Text
Whitespace cleanup is string manipulation, so it needs no server. The whole tool is JavaScript running in the tab you have open: your text is read from the textarea, transformed in memory, and written into the result box beside it. There is no API call, no upload, no database, no account and no copy of your text logged or stored. You can confirm it yourself in your browser’s developer tools: typing, pasting and changing options send nothing anywhere, because the tool itself never makes a request. What the page does load — a web font and this site’s own anonymous view counter — cannot see the textarea, and the tool works identically with the connection off.
That matters more for this kind of tool than it sounds. The text people clean is often text they are not free to paste into a third-party service: a contract clause, an internal log, financial figures, a manuscript that has not been published, patient or customer records, an exam paper, a pre-announcement. Those go into this page and nowhere else.
The honest caveat is the same one that applies to any local editor: while you work, the text is in your browser’s memory, and after you press Copy Output it is on your clipboard, where anything with clipboard access could read it. What does not happen is transmission. No text leaves the device, and closing the tab discards it.
Frequently Asked Questions
How do I remove extra spaces from text online?
Paste your text into the box and the cleaned version appears beside it immediately. There is nothing to submit and no button to run. The defaults handle the common case: runs of two or more spaces collapse to one, whitespace at the start and end of each line is trimmed, tabs become a single space, and non-breaking and zero-width spaces are normalised or removed. Press Copy Output when the result looks right. The What changed panel under the options counts the characters and spaces removed, so you can see what happened before you copy it. Nothing is uploaded at any point.
How do I remove double spaces between words?
Switch on Collapse multiple spaces, which is already on by default. Every run of two or more spaces becomes exactly one, while a single space between two words is never touched, so normal word separation survives. It works on runs of three, four or twenty, and it works on mixed whitespace: because tabs are converted and unusual spaces are normalised first, a gap made of one space plus one non-breaking space plus one tab is still recognised as a run and still collapses. It never crosses a line break, so your paragraphs keep their shape. If you want to keep the traditional two spaces after a full stop, switch the option off and target the specific pattern with Find & Replace Text instead.
Can I remove leading and trailing spaces?
Yes — Remove leading & trailing spaces is on by default and works on every line, including the first and last, so a stray margin of spaces at the top or bottom of a paste goes as well. Trailing whitespace is worth removing even though you cannot see it: it makes two identical-looking lines unequal to a computer, so sorts come out in an arbitrary order, duplicate checks miss them, exact-match lookups fail, Markdown reads it as a hard line break and diff tools show it as a change to a line nobody edited. Leading whitespace is a different question, because sometimes it is the formatting. That is what Preserve indentation is for.
Can this tool remove tabs?
It converts them, which is usually what you actually want. The Tabs group offers 1, 2, 4 or 8 spaces, and the default is one. Converting is worth doing because a tab has no fixed width: the same file shows as two spaces in one editor, four in another and eight in a terminal, so a column that looks aligned on your screen looks ragged on somebody else’s. Replacing every tab with a fixed number of spaces removes that ambiguity. The conversion is applied to every tab, including the ones holding your indentation, and the What changed panel counts how many were converted. If the file is meant to stay tab-indented — a tab-separated export, or code in a tab style — choose Leave tabs alone and the other rules work around them. If you want tabs deleted rather than replaced, Remove Line Breaks has a Clean tabs option for that.
Can I remove blank lines?
Yes, with Remove blank lines, which is off by default. It drops rows that are completely empty and rows that contain only spaces or tabs, so a line that looks blank but is holding three spaces goes too. A row is judged on how it arrived, not on what the other options do to it, so the behaviour is predictable. Multiple consecutive blank lines all go; the option never leaves one behind. It is off by default because in prose a blank line is usually a paragraph break, and deleting those turns a document into a wall of text. Check first, or keep the option off and use Remove Line Breaks, which understands paragraph structure and can preserve the breaks deliberately.
What are invisible or non-breaking spaces?
They are Unicode characters that occupy horizontal space but are not the ordinary space U+0020. The best known is the non-breaking space U+00A0 — HTML’s — which a browser inserts to stop a line breaking between a number and its unit. There is also a family of typographic spaces (en, em, thin, hair, narrow non-breaking U+202F, medium mathematical U+205F, the ideographic space U+3000, the Ogham space mark U+1680). They all render as a gap, and because none of them is U+0020, a rule looking for two spaces in a row walks straight past them, which is why a space you can clearly see sometimes refuses to collapse or delete. Separately there are zero-width characters that occupy no space at all and are invisible: the byte-order mark U+FEFF and the zero-width space U+200B, both common copy/paste artefacts that break searches, character counts and exact matches. With Normalize invisible spaces on, the width-bearing ones become ordinary spaces and the two artefacts are deleted. Three zero-width characters are never touched because they carry meaning: U+200D holds emoji families and Indic conjuncts together, U+200C changes letter shapes in Persian, Arabic and Devanagari, and U+2060 controls line breaking.
Can I clean text copied from a PDF?
That is the single most common use for this page. A PDF stores text as positioned glyphs rather than as paragraphs, so when you copy, the reader reconstructs the words from their coordinates and guesses at the gaps. Justified text is the worst case, because the renderer stretched the word gaps to line up the right-hand edge and the copy carries the stretch with it: one sentence can contain gaps of two, three and four spaces. Line ends pick up trailing spaces, numbers arrive attached to their units with a non-breaking space, and headers and footers are often repeated on every page. Leave the defaults on: collapse, trim and normalise invisible spaces handle all of that. Two extras help: if the copy also has a hard line break at the end of every visual line, run Remove Line Breaks first to restore the paragraphs, and if the header or footer repeated, Remove Duplicate Lines will drop the copies.
Can I remove extra spaces from ChatGPT text?
Yes. Language models emit Markdown, and Markdown uses whitespace structurally — two trailing spaces mean a hard line break, four leading spaces mean a code block, a blank line separates paragraphs — so pasted into a plain text box those conventions become stray trailing spaces and unexplained indentation. Models also frequently use non-breaking spaces inside numbers and units, writing 12 kg and EUR 500, which look right on screen and then break a search or a sort. The defaults fix both. If the text is still full of asterisks, hashes and hedging, ChatGPT Text Cleaner handles the Markdown and the filler, AI Text Cleaner works on AI output from any source, and this page deals with the whitespace that is left over.
Will this tool destroy my indentation?
Only if you ask it to. Preserve indentation is off by default, because most pastes are prose and prose has no indentation to preserve. With it off, leading whitespace is treated as noise and trimmed. Switch it on and the leading run of spaces and tabs on every line is kept exactly as it is, neither collapsed nor trimmed, while everything after it is still cleaned. A block of Python keeps its four-space levels and still loses the doubled spaces inside the code; a nested list keeps its depth while each bullet tightens up. It is the option to reach for with code, lists, poetry, tables aligned by hand, ASCII diagrams and any text where the left-hand edge carries meaning. One interaction is worth knowing: tabs are converted before indentation is preserved, so with Preserve indentation on and Tabs set to 4, a tab-indented block becomes a consistently four-space-indented block rather than a mixture. Choose Leave tabs alone if you want the tabs themselves kept. No option on this page ever changes a letter, a digit or a word.
What does "Remove all spaces" do, and when should I use it?
It is a separate mode, not a checkbox, precisely so that nobody switches it on while cleaning prose. It deletes every space, tab and invisible space between characters and keeps your line breaks, so Quarterly review becomes Quarterlyreview and a phone number written 020 7946 0958 becomes 02079460958. Letters, digits, punctuation and the meaningful zero-width joiners are untouched. That is exactly right for a column of product codes, a list of identifiers, a hashtag that picked up a gap or a compact string that has to match a machine-readable format, and exactly wrong for anything meant to be read. The panel warns you while the mode is active, and switching back to Clean whitespace restores everything, because the result is recalculated from your input on every change, so nothing is ever applied destructively to the text you typed.
Is my text uploaded or stored?
No. Removing whitespace is string manipulation, so it needs no server: the whole tool is JavaScript running in the tab you have open. There is no API call, no upload, no database, no account and no copy of your text logged or stored, and you can verify that in your browser’s developer tools: the tool itself never makes a request, so typing and changing options send nothing anywhere. It works with the connection off. That matters when the text is a contract clause, an internal log, financial figures, an unseen manuscript or a customer record. The one honest caveat is that the text is in your browser’s memory while you work and, after you press Copy, on your clipboard, exactly as it would be in any local editor. What does not happen is transmission.