[{"data":1,"prerenderedAt":605},["ShallowReactive",2],{"blog-how-to-remove-extra-spaces-from-text-online":3},{"id":4,"title":5,"alt":6,"author":7,"body":8,"category":566,"description":567,"extension":568,"faq":569,"image":591,"meta":592,"navigation":593,"path":594,"publishedAt":595,"seo":596,"stem":597,"tags":598,"__hash__":604},"blog\u002Fen\u002Fhow-to-remove-extra-spaces-from-text-online.md","How to Remove Extra Spaces From Text Online (Fast Fix)","Text before and after removing extra spaces, showing double spaces and non-breaking spaces cleaned up","WordCount Team",{"type":9,"value":10,"toc":551},"minimark",[11,15,18,23,35,38,174,177,181,184,189,192,202,205,209,212,218,221,225,232,238,241,245,248,340,343,347,355,360,366,377,382,388,399,404,410,413,421,425,428,451,469,480,484,487,493,504,508,511,542,545,548],[12,13,14],"p",{},"If you've ever pasted content from a PDF, a Word document, or a web page and ended up with double spaces between every word, you've hit one of text editing's most common annoyances. Those aren't display glitches — they're real characters embedded in your content, and they don't go away on their own.",[12,16,17],{},"Here's how to remove them fast.",[19,20,22],"h2",{"id":21},"the-fast-way-use-the-remove-spaces-tool","The Fast Way: Use the Remove Spaces Tool",[12,24,25,26,34],{},"Paste your text into our ",[27,28,29],"strong",{},[30,31,33],"a",{"href":32},"\u002Fremove-spaces","Remove Spaces"," — runs 100% in your browser tab, your text is never transmitted to any server — select the operations you need, and copy the cleaned result. Done in seconds.",[12,36,37],{},"The tool covers seven specific cleanup operations:",[39,40,41,57],"table",{},[42,43,44],"thead",{},[45,46,47,51,54],"tr",{},[48,49,50],"th",{},"Operation",[48,52,53],{},"What it fixes",[48,55,56],{},"Before → After",[58,59,60,79,95,111,127,143,159],"tbody",{},[45,61,62,66,69],{},[63,64,65],"td",{},"Remove extra spaces",[63,67,68],{},"Multiple spaces collapsed into one",[63,70,71,75,76],{},[72,73,74],"code",{},"word  word"," → ",[72,77,78],{},"word word",[45,80,81,84,87],{},[63,82,83],{},"Fix PDF line breaks",[63,85,86],{},"Mid-sentence hard returns removed",[63,88,89,75,92],{},[72,90,91],{},"quick brown\\nfox",[72,93,94],{},"quick brown fox",[45,96,97,100,103],{},[63,98,99],{},"Remove all line breaks",[63,101,102],{},"Entire document flattened to one block",[63,104,105,75,108],{},[72,106,107],{},"line 1\\nline 2",[72,109,110],{},"line 1 line 2",[45,112,113,116,119],{},[63,114,115],{},"Remove empty lines",[63,117,118],{},"Blank lines between paragraphs stripped",[63,120,121,75,124],{},[72,122,123],{},"para\\n\\n\\npara",[72,125,126],{},"para\\n\\npara",[45,128,129,132,135],{},[63,130,131],{},"Trim line endings",[63,133,134],{},"Leading\u002Ftrailing spaces per line removed",[63,136,137,75,140],{},[72,138,139],{},"·· hello ··",[72,141,142],{},"hello",[45,144,145,148,151],{},[63,146,147],{},"Remove special characters",[63,149,150],{},"Non-ASCII chars stripped",[63,152,153,75,156],{},[72,154,155],{},"résumé",[72,157,158],{},"resume",[45,160,161,164,167],{},[63,162,163],{},"Straighten quotes",[63,165,166],{},"Curly typographic quotes → ASCII straight",[63,168,169,75,172],{},[72,170,171],{},"\"hello\"",[72,173,171],{},[12,175,176],{},"Select one or several — they stack. The preview pane shows exactly what changed before you copy anything.",[19,178,180],{"id":179},"why-pasted-text-arrives-with-extra-spaces","Why Pasted Text Arrives With Extra Spaces",[12,182,183],{},"Understanding the source makes the fix less mysterious.",[185,186,188],"h3",{"id":187},"pdfs-geometry-not-text","PDFs: Geometry, Not Text",[12,190,191],{},"PDFs store text as glyph coordinates, not character strings. Extraction is a reverse-engineering job:",[193,194,199],"pre",{"className":195,"code":197,"language":198},[196],"language-text","PDF internal:  [glyph \"w\" at x=100] [glyph \"o\" at x=108] ... [glyph \"w\" at x=180] ...\n                                                                 ↑ gap = 22px\nExtractor:     \"word\" + \"  \" + \"word\"    ← gap > threshold → two spaces inserted\n","text",[72,200,197],{"__ignoreMap":201},"",[12,203,204],{},"If the coordinate gap between two words is slightly wider than the extractor's threshold — common with justified text or wide kerning — it inserts two spaces. Every word pair potentially affected. It's not a bug; it's a geometry inference with no perfect answer.",[185,206,208],{"id":207},"word-and-indesign-intentional-nbsp","Word and InDesign: Intentional NBSP",[12,210,211],{},"Microsoft Word and InDesign insert non-breaking spaces (U+00A0) in specific positions:",[193,213,216],{"className":214,"code":215,"language":198},[196],"You type:    10 kg\nWord stores: 10[U+00A0]kg   ← non-breaking space, prevents line-wrap between number and unit\nYou see:     10 kg          ← looks identical to a regular space\n",[72,217,215],{"__ignoreMap":201},[12,219,220],{},"Legitimate typographic behavior in a word processor. Invisible contamination the moment you paste into any other context.",[185,222,224],{"id":223},"html-copy-paste-the-nbsp-trap","HTML Copy-Paste: The &nbsp; Trap",[12,226,227,228,231],{},"Any ",[72,229,230],{},"&nbsp;"," entity in the source HTML arrives as U+00A0 in your clipboard:",[193,233,236],{"className":234,"code":235,"language":198},[196],"HTML source:   \u003Ctd>New&nbsp;York\u003C\u002Ftd>\nClipboard:     New[U+00A0]York\nText editor:   New York    ← looks fine, behaves broken\n",[72,237,235],{"__ignoreMap":201},[12,239,240],{},"Paste a table from a website into a plain text field and you've got dozens of them.",[19,242,244],{"id":243},"the-five-space-characters-that-cause-problems","The Five Space Characters That Cause Problems",[12,246,247],{},"Not all \"spaces\" are the same character. Here are the ones you'll actually encounter:",[39,249,250,266],{},[42,251,252],{},[45,253,254,257,260,263],{},[48,255,256],{},"Character",[48,258,259],{},"Unicode",[48,261,262],{},"How it arrives",[48,264,265],{},"Visible difference",[58,267,268,282,298,312,326],{},[45,269,270,273,276,279],{},[63,271,272],{},"Regular space",[63,274,275],{},"U+0020",[63,277,278],{},"Typed normally",[63,280,281],{},"None",[45,283,284,287,290,295],{},[63,285,286],{},"Non-breaking space",[63,288,289],{},"U+00A0",[63,291,292,293],{},"Word, InDesign, HTML ",[72,294,230],{},[63,296,297],{},"None — invisible",[45,299,300,303,306,309],{},[63,301,302],{},"Zero-width space",[63,304,305],{},"U+200B",[63,307,308],{},"CMS exports, Markdown parsers",[63,310,311],{},"None — truly invisible",[45,313,314,317,320,323],{},[63,315,316],{},"Em space",[63,318,319],{},"U+2003",[63,321,322],{},"Design tools, some CMSs",[63,324,325],{},"Slightly wider",[45,327,328,331,334,337],{},[63,329,330],{},"Thin space",[63,332,333],{},"U+2009",[63,335,336],{},"Typographic templates",[63,338,339],{},"Slightly narrower",[12,341,342],{},"The Remove Spaces tool targets all of these. The regex approach requires explicit Unicode code points for each one — which brings us to the manual method.",[19,344,346],{"id":345},"the-manual-regex-approach","The Manual Regex Approach",[12,348,349,350,354],{},"If you're processing multiple documents, building a pipeline, or just prefer to understand what's happening, the ",[30,351,353],{"href":352},"\u002Ffind-replace","Find & Replace"," tool handles this with regex patterns.",[12,356,357],{},[27,358,359],{},"Collapse double spaces:",[193,361,364],{"className":362,"code":363,"language":198},[196],"Find:    [ \\t]+\nReplace: (single space)\nFlags:   g\n",[72,365,363],{"__ignoreMap":201},[12,367,368,369,372,373,376],{},"Using ",[72,370,371],{},"\\s+"," instead would also eat your newlines — don't do that unless you want one giant paragraph. ",[72,374,375],{},"[ \\t]+"," targets horizontal whitespace only.",[12,378,379],{},[27,380,381],{},"Replace non-breaking spaces:",[193,383,386],{"className":384,"code":385,"language":198},[196],"Find:     \nReplace: (regular space)\nFlags:   gu\n",[72,387,385],{"__ignoreMap":201},[12,389,390,391,394,395,398],{},"The ",[72,392,393],{},"u"," flag is required. Without it, ",[72,396,397],{}," "," is treated as a literal string, not a Unicode escape, and the pattern silently matches nothing.",[12,400,401],{},[27,402,403],{},"Fix PDF line break artifacts:",[193,405,408],{"className":406,"code":407,"language":198},[196],"Find:    (?\u003C!\\n)\\n(?!\\n)\nReplace: (space)\nFlags:   g\n",[72,409,407],{"__ignoreMap":201},[12,411,412],{},"This negative lookahead\u002Flookbehind pattern removes single newlines (the mid-sentence artifact ones) while leaving double newlines intact, so your paragraph breaks survive. More surgical than \"remove all line breaks.\"",[12,414,415,416,420],{},"For a deeper look at pattern syntax, capture groups, and quantifiers, the ",[30,417,419],{"href":418},"\u002Fblog\u002Fregex-find-replace-guide","regex find & replace guide"," covers the full reference.",[19,422,424],{"id":423},"non-breaking-spaces-the-invisible-problem","Non-Breaking Spaces: The Invisible Problem",[12,426,427],{},"Worth extra attention, because U+00A0 causes downstream issues that regular double spaces don't.",[12,429,430,433,434,437,438,441,442,446,447,450],{},[27,431,432],{},"Word count mismatch."," A naive whitespace split (",[72,435,436],{},"text.split(' ')",") won't split on U+00A0. ",[72,439,440],{},"\"New York\""," with NBSP stays as one token. Our ",[30,443,445],{"href":444},"\u002F","Word Counter"," uses ",[72,448,449],{},"Intl.Segmenter"," — the W3C standard API for language-aware tokenization — which handles Unicode whitespace correctly. But paste your text into any platform that uses a simpler approach, and your count will be off.",[12,452,453,456,457,460,461,464,465,468],{},[27,454,455],{},"Regex patterns break silently."," ",[72,458,459],{},"\\s"," in JavaScript matches tab, space, newline, carriage return — but not U+00A0 by default. A pattern like ",[72,462,463],{},"\u002F\\s+\u002Fg"," will skip every non-breaking space without warning. If you're writing regex to process user-pasted content, add U+00A0 explicitly: ",[72,466,467],{},"[ \\t ]+",".",[12,470,471,474,475,479],{},[27,472,473],{},"Copy-paste contamination in document formatting."," This is the same category of invisible-character problem covered in ",[30,476,478],{"href":477},"\u002Fblog\u002Fhow-many-words-per-page","how many words per page"," — characters that look fine on screen but throw off character counts, line lengths, and page layout calculations.",[19,481,483],{"id":482},"zero-width-spaces-the-other-invisible-character","Zero-Width Spaces: The Other Invisible Character",[12,485,486],{},"Zero-width spaces (U+200B) appear in text exported from CMSs like WordPress, Contentful, and Notion, and from some Markdown parsers. Genuinely invisible — no width at all.",[193,488,491],{"className":489,"code":490,"language":198},[196],"Looks like:  wordhere\nActually is: word[U+200B]here\nCode sees:   two tokens: \"word\" + \"here\"\n",[72,492,490],{"__ignoreMap":201},[12,494,495,496,499,500,503],{},"Your editor won't highlight it. Spell check ignores it. But word tokenization and character counts see it. To strip them: Find ",[72,497,498],{},"​",", replace with nothing, ",[72,501,502],{},"gu"," flags — or run \"Remove special characters\" in the Remove Spaces tool, which targets all non-ASCII whitespace variants in one pass.",[19,505,507],{"id":506},"before-you-clean-a-30-second-triage","Before You Clean: A 30-Second Triage",[12,509,510],{},"Not every document needs all seven operations. A quick check first:",[512,513,514,521,530,536],"ol",{},[515,516,517,520],"li",{},[27,518,519],{},"Search for two consecutive spaces."," If you get matches → double-space contamination from PDF or old typewriting habit.",[515,522,523,529],{},[27,524,525,526,528],{},"Search for ",[72,527,397],{}," in a regex-capable editor."," Matches → non-breaking space contamination from Word or HTML.",[515,531,532,535],{},[27,533,534],{},"Look for lines that cut off mid-sentence."," Signature of PDF column extraction artifacts.",[515,537,538,541],{},[27,539,540],{},"Check if paragraph spacing looks inconsistent."," Multiple empty lines between paragraphs → an \"empty lines\" cleanup pass will normalize it.",[12,543,544],{},"Knowing which problem you have means running only the operations you need — and the preview pane confirms the result before you commit.",[546,547],"hr",{},[12,549,550],{},"Extra spaces are one of those formatting problems that feel minor until they aren't — until your word count is wrong, your regex fails, or your client asks why the document looks different in every paragraph. Two minutes of cleanup at paste time saves significantly more time downstream.",{"title":201,"searchDepth":552,"depth":552,"links":553},2,[554,555,561,562,563,564,565],{"id":21,"depth":552,"text":22},{"id":179,"depth":552,"text":180,"children":556},[557,559,560],{"id":187,"depth":558,"text":188},3,{"id":207,"depth":558,"text":208},{"id":223,"depth":558,"text":224},{"id":243,"depth":552,"text":244},{"id":345,"depth":552,"text":346},{"id":423,"depth":552,"text":424},{"id":482,"depth":552,"text":483},{"id":506,"depth":552,"text":507},"Writing Tips","Paste-and-fix: remove double spaces, non-breaking spaces, and PDF line breaks in seconds. Free browser tool, no upload required.","md",[570,573,576,579,582,585,588],{"question":571,"answer":572},"Why does pasted text have extra spaces?","PDFs store text as x\u002Fy coordinates, not character strings. When a PDF reader extracts text, it infers word boundaries from the distance between glyph positions — if the gap is wider than expected, it inserts two spaces instead of one. Microsoft Word and InDesign add non-breaking spaces (U+00A0) after abbreviations, between numbers and units (\"10 kg\"), and after certain punctuation. HTML content pasted from a browser often includes &amp;nbsp; entities that arrive as U+00A0. None of these look different from a regular space on screen, but they break word counts, search indexing, and pattern matching.",{"question":574,"answer":575},"What is a non-breaking space and why is it invisible?","A non-breaking space (Unicode U+00A0) is a space character that prevents a line break at that position. Word processors use it intentionally — 'New York' with a non-breaking space stays on the same line rather than splitting across two. The problem: it looks exactly like a regular space (U+0020) in any text editor or word processor. It only reveals itself when you paste into a code editor, run a regex that skips it, or notice a word count tool reading 'New York' (with NBSP) as one word instead of two. The Remove Spaces tool detects and replaces U+00A0 with regular spaces.",{"question":577,"answer":578},"What regex pattern removes multiple spaces in a row?","To collapse any run of two or more regular spaces into one, use: \u002F[ \\t]+\u002Fg with a single space as the replacement. This targets horizontal whitespace only — it won't accidentally collapse your paragraph breaks. To also catch non-breaking spaces in the same pass: \u002F[ \\t\\u00A0]+\u002Fgu — note the u flag, required for Unicode property matching in JavaScript. Avoid \u002F\\s+\u002Fg for this task — \\s matches newlines too, which will flatten your entire document into one paragraph.",{"question":580,"answer":581},"Why does the Remove Spaces tool have a separate 'Fix PDF line breaks' option?","PDF text extraction produces two distinct problems needing different fixes. 'Remove extra spaces' collapses multiple spaces into one. 'Fix PDF line breaks' addresses mid-sentence newlines — when you copy text from a two-column PDF, each line ends with a hard return, so 'the quick brown\\nfox jumps over' becomes two lines instead of one sentence. The fix removes single newlines (while preserving genuine paragraph breaks — double newlines) and reattaches hyphenated line-end words like 'infor-\\nmation' back into 'information'.",{"question":583,"answer":584},"Does removing extra spaces change my word count?","Removing regular double spaces does not change word count — word boundaries are determined by letter sequences, not space counts. But replacing non-breaking spaces (U+00A0) with regular spaces can change word count, because a non-breaking space glued between words causes a tokenizer to read 'New York' (with NBSP) as one token. After cleanup with regular spaces, it correctly counts as two words. If you notice a jump in word count after running the space fixer, that's the tokenizer now reading your text correctly.",{"question":586,"answer":587},"Can I remove spaces from a very large document without the page freezing?","Yes. All processing in the Remove Spaces tool runs in your browser's JavaScript engine — no file is uploaded anywhere. For typical documents (up to around 50,000 words), the operations complete in under 50ms. For anything a person would realistically paste — blog posts, emails, legal briefs, academic papers — it handles it instantly without UI lag.",{"question":589,"answer":590},"What is the difference between 'Trim line endings' and 'Remove extra spaces'?","'Remove extra spaces' collapses multiple consecutive spaces within a line into a single space. 'Trim line endings' removes leading and trailing spaces at the start and end of each individual line. A line like '  hello  world  ' has both issues — trim cleans the edges to 'hello  world', then the space collapsing step turns it into 'hello world'. Running both together is how you get a fully normalized line.","\u002Farticles\u002Fhow-to-remove-extra-spaces-from-text-online.webp",{},true,"\u002Fen\u002Fhow-to-remove-extra-spaces-from-text-online","2026-05-08",{"title":5,"description":567},"en\u002Fhow-to-remove-extra-spaces-from-text-online",[599,600,601,602,603],"remove extra spaces","text formatting","non-breaking spaces","PDF text cleanup","find and replace","5lNtm2knQ82oKkyKPL-9GcpLMRBzto_8GgaJkUUjMkY",1778416900070]