Whitespace Remover: Delete Extra or All Spaces
Found in the original → left in the result
No extra or invisible spaces.
- double and longer spaces: 0 → 0
- lines with padding: 0 → 0
- tabs: 0 → 0
- non-breaking spaces: 0 → 0
- other Unicode spaces: 0 → 0
- zero-width characters: 0 → 0
- soft hyphens, direction marks, fillers: 0 → 0
- spaces before punctuation: 0 → 0
- extra blank lines: 0 → 0
Show invisible characters
· space, → tab, ° non-breaking space, ¶ line end, a code for any other invisible character. Everything except ordinary single spaces is highlighted.
The first 4,000 characters are shown.
Cleaning rules, replacing spaces, indentation
Paste the text and the extra spaces are removed at once; words and lines stay. To remove all spaces or line breaks, or to clean numbers, press a mode under the boxes:
| Mode | Before | After |
|---|---|---|
| Extra spaces | Hello···big··world | Hello big world |
| All spaces | 4111 1111 1111 1111 | 4111111111111111 |
| One line | Hello ¶ world | Hello world |
| Numbers | 1 250 000.50 | 1250000.50 |
all ten modes ↓ · what hidden spaces break ↓ · every invisible character ↓ · the same in Excel, Word and code ↓
Ten modes for ten kinds of mess, from double spaces to a heading spelled C H A P T E R. The report under the boxes counts what was found and what is left, and one click shows where the tabs, non-breaking spaces and zero-width characters stand. Any rule can be switched on or off by itself.
Your text is cleaned locally in your browser and never sent to a server.
Ten modes, before and after
A dot on a highlight is a repeated space or one at a line edge, a highlight without a dot is a non-breaking space, → is a tab and ¶ a line end. The After column is produced by the same code as the boxes above; Try it loads the example there.
Ten modes with examples
| Mode and what it is for | Before | After | Try |
|---|---|---|---|
| Extra spaces Double spaces, tabs and padding. One space stays between words, lines stay | ··Invoice···No. ·2026→paid· | Invoice No. 2026 paid | |
| All spaces Card numbers, phones, codes in a column. Lines stay | 4111 1111 1111 1111 ¶ +1 (212) 555 0100 | 4111111111111111 ¶ +1(212)5550100 | |
| All whitespace Base64, keys and hashes that have to be one unbroken string | MIIB IjAN ¶ Bgkq hkiG | MIIBIjANBgkqhkiG | |
| One line An address or a list that has to fit one field | 5 Main St ¶ ··Springfield ¶ ¶ IL 62701 | 5 Main St Springfield IL 62701 | |
| Blank lines Empty space between lines. Nothing inside the lines changes | Milk ¶ ¶ ··Eggs ¶ ¶ ¶ Bread | Milk ¶ ··Eggs ¶ Bread | |
| PDF text Sentences and words broken into lines. Paragraphs stay apart | The contract takes··ef- ¶ fect on the day of signing. ¶ ¶ Term: one year. | The contract takes effect on the day of signing. ¶ ¶ Term: one year. | |
| Spreadsheet Cells copied from Excel or Sheets. Columns and empty rows stay put | ·Anna··Lee·→42· ¶ Bo Chen·→·17 | Anna Lee→42 ¶ Bo Chen→17 | |
| Numbers Amounts Excel reads as text. Only groups of three digits close up | 1 250 000.50 and 48 300, tel. 1 212 555 0100 | 1250000.50 and 48300, tel. 1 212 555 0100 | |
| Spaced letters Headings spaced out letter by letter in a PDF or a scan | C H A P T E R···O N E | CHAPTER ONE | |
| Code Trailing spaces and invisible characters. Indentation stays | if x:·· ¶ ····y = 1→ | if x: ¶ ····y = 1 |
When a gap is not a space
Some gaps hold no characters, so no text tool can remove them. Wide gaps in one line of Word or a web page are usually justified alignment: press Ctrl+L. Letters set apart without dots between them in Show invisible characters are letter spacing, in Word Ctrl+D, Advanced, Spacing: Normal. Space between paragraphs with no empty line is paragraph spacing.
White margins around a picture are a job for the image cropper, and blank pages in a document for deleting PDF pages.
Example: an invoice copied from a PDF
On screen these lines look nearly right, yet a search for “Acme Ltd” finds nothing: a zero-width character stands after Acme.
···Client: AcmeU+200B Ltd. ¶
¶
¶
¶
Total:→U+20091 240.00 € , VAT incl.
Client: Acme Ltd. ¶
¶
Total: 1 240.00 € , VAT incl.
74 characters in, 65 out, 13 words both times. The report (found → left): double and longer spaces 3 → 0, lines with padding 1 → 0, tabs 1 → 0, non-breaking spaces 3 → 0, other Unicode spaces 1 → 0, zero-width characters 1 → 0, spaces before punctuation 1 → 1, extra blank lines 2 → 0. The space before the comma is left for the rule Remove spaces before punctuation, and the one inside 1 240.00 for Numbers.
What hidden whitespace breaks
In the expressions ⍽ is a non-breaking space U+00A0. Both result columns were computed, the second one on the cleaned string.
Five symptoms and checks
| What you see | Check | As pasted | Cleaned |
|---|---|---|---|
| VLOOKUP and filters do not find a value that is there | "Acme⍽Ltd" === "Acme Ltd" | false | true |
| A field is over its limit by one or two characters | "Acme⟨U+200B⟩ Ltd".length | 9 | 8 |
| %C2%A0 in the middle of a link | encodeURIComponent("Acme⍽Ltd") | Acme%C2%A0Ltd | Acme%20Ltd |
| Splitting on a space gives one word instead of two | "Acme⍽Ltd".split(" ").length | 1 | 2 |
| An amount is text and does not add up (Numbers mode) | Number("1⟨U+202F⟩240") | NaN | 1240 |
Two lines that look the same but show as changed in a text diff usually differ by one of these, and imported CSV values stop matching for the same reason.
Every invisible character the tool knows
The default rules handle 22 code points. A \s regex misses 5 of them in JavaScript and 6 in Python. To check a document, put the decimal number after ^u in the Find box of Word (^u8203), or search an Excel cell with =FIND(UNICHAR(8203),A1).
Characters handled by default
| Code | Decimal | Name | Where it comes from | JS \s | Python \s | What happens |
|---|---|---|---|---|---|---|
| U+00A0 | 160 | No-break space | Word, on web pages, PDF text | yes | yes | becomes a plain space |
| U+202F | 8239 | Narrow no-break space | Amounts, dates, French text | yes | yes | becomes a plain space |
| U+2000–200A | 8192–8202 | En, em, thin, hair and other fixed-width spaces | InDesign, LaTeX, PDF typesetting | yes | yes | becomes a plain space |
| U+205F | 8287 | Medium mathematical space | Formula editors, MathML | yes | yes | becomes a plain space |
| U+3000 | 12288 | Ideographic (full-width) space | Japanese and Chinese text | yes | yes | becomes a plain space |
| U+1680 | 5760 | Ogham space mark | Old Irish script | yes | yes | becomes a plain space |
| U+180E | 6158 | Mongolian vowel separator | Old texts; not a space since Unicode 6.3 | no | no | becomes a plain space |
| U+200B | 8203 | Zero-width space | CMS exports, line-break hints in HTML | no | no | deleted |
| U+200C | 8204 | Zero-width non-joiner | Persian and Hindi text | no | no | deleted; kept inside a Persian or Hindi word |
| U+200D | 8205 | Zero-width joiner | Multi-part emoji | no | no | deleted; kept between two emoji |
| U+2060 | 8288 | Word joiner | Hand-written HTML | no | no | deleted |
| U+FEFF | 65279 | Byte-order mark | The start of a UTF-8 file, joined files | yes | no | deleted |
Blank characters that are not spaces
20 more code points print nothing and are not whitespace to Unicode, so neither \s nor a space remover touches them. The report counts them; the rule “Delete soft hyphens, direction marks, blank fillers” removes them. It is off by default, because Arabic and Hebrew text may need its direction marks.
Blank characters: codes and sources
| Code | Decimal | Name | Where it comes from | What happens |
|---|---|---|---|---|
| U+00AD | 173 | Soft hyphen | Web pages and e-books, at syllable breaks | deleted |
| U+200E–200F | 8206–8207 | Left-to-right and right-to-left marks | Certificate thumbprints copied from Windows, mixed-direction text | deleted |
| U+202A–202E | 8234–8238 | Direction embeddings and overrides | File paths and phone numbers copied from Windows, fake file names | deleted |
| U+2066–2069 | 8294–8297 | Direction isolates | Names and quotes inside right-to-left text | deleted |
| U+061C | 1564 | Arabic letter mark | Arabic text | deleted |
| U+2061–2064 | 8289–8292 | Invisible math operators | Formula editors | deleted |
| U+2800 | 10240 | Braille blank | “Invisible character” sites, blank nicknames | becomes a plain space |
| U+3164 | 12644 | Hangul filler | Blank nicknames and messages | becomes a plain space |
| U+FFA0 | 65440 | Half-width Hangul filler | Blank nicknames and messages | becomes a plain space |
The same job in Excel, Word and code
For one column or one field it is easier to clean the data where it is. The third column is how many of the 22 characters above the formula handles; a dash means it depends on the settings.
Excel, Word and code recipes
| Where | What to run | Of 22 | Watch for |
|---|---|---|---|
| Excel, extra spaces | =TRIM(A1) | 0 | Only character 32, the ordinary space |
| Excel, with no-break spaces | =TRIM(SUBSTITUTE(CLEAN(A1),CHAR(160)," ")) | 1 | CLEAN also deletes line breaks inside the cell |
| Excel, all spaces | =SUBSTITUTE(SUBSTITUTE(A1," ",""),CHAR(160),"") | 1 | The result is text; wrap it in VALUE() if it is a number |
| Google Sheets | =TRIM(REGEXREPLACE(A1,"[\s\x{00A0}]+"," ")) | 1 | \s alone is ASCII only in RE2, the regex engine of Sheets |
| Word, double spaces | Ctrl+H → More → Use wildcards Find: ( ){2,} Replace with: \1 | — | Finds ordinary spaces only; ^s (wildcards off) finds a no-break space |
| JavaScript | s.replace(/[^\S\n]+/g, " ") s.replace(/\s+/g, "") | 17 | U+200B, U+200C, U+200D, U+2060 and U+180E stay |
| Python | " ".join(s.split()) re.sub(r"\s+", "", s) | 16 | The JavaScript five stay, and so does U+FEFF |
| Shell | sed -E 's/[[:space:]]+/ /g; s/^ +| +$//g' awk '{$1=$1};1' | — | Depends on the locale; in the C locale it is ASCII only |
| VS Code | Trim Trailing Whitespace (command palette) Find with regex on: [ \t]{2,} | — | Zero-width characters need their own search, for example \u200b |
| JavaScript, everything | s.replace(/[\u200b-\u200d\u2060\ufeff]/g, "").replace(/[\s\u180e]+/g, " ").trim() | 22 | Also joins lines and breaks multi-part emoji, which this page keeps |
The order in the last row matters: delete the zero-width characters first, or a space appears inside a word. Sources: Microsoft on TRIM and character 160, the RE2 syntax and Python's re. To test a pattern on your own text, use the regex tester.
How it works
- 1 Paste the text or open a file Put the text into the Original text box or drop a .txt, .csv or .md file on it. The result appears as you type. If the paste looks like a spreadsheet, code or PDF text, the page offers the mode for it.
- 2 Pick a mode Extra spaces is on from the start. All spaces keeps the lines, All whitespace does not, One line joins everything, Spreadsheet keeps the columns, Code keeps the indentation. Single rules are in the list below, with a choice of what to put in place of the spaces.
- 3 Check the report and take the result Each line of the report shows how many characters of that kind were in the original and how many are left. Copy the result, download it as .txt, or send it back to the first box for another pass; Undo returns the old text.
Frequently asked questions
- What is the difference between extra spaces, all spaces and all whitespace?
- Extra spaces leaves one space between words and keeps the lines: a···b (a dot is a space) becomes a·b. All spaces deletes every space and tab but keeps the lines, so a column of card numbers stays a column: 4111 1111 1111 1111 becomes 4111111111111111. All whitespace deletes the line breaks too and leaves one unbroken string.
- How do I remove spaces but keep the line breaks?
- Both Extra spaces and All spaces keep the lines. The first one leaves a single space between words, the second one leaves none. Runs of blank lines become one blank line; untick Merge repeated blank lines to keep them all.
- How do I remove the empty space between lines?
- Choose Blank lines. Every line with nothing but spaces or tabs in it goes, and the text inside the other lines is not touched. If the gap stays, it is not an empty line but paragraph spacing: in Word select the text and set Layout, Spacing to 0 before and after.
- How do I clean Excel cells without losing the columns?
- Choose Spreadsheet. Copied cells are separated by tabs, and an ordinary cleaner turns those tabs into spaces, so everything lands in one column when pasted back. This mode cleans each cell by itself, keeps tabs and empty rows, and the result pastes back into the same cells.
- Why does Excel's TRIM leave spaces in place?
- TRIM removes only character 32, the ordinary space. Text from a web page or a PDF often holds character 160, the non-breaking space, and Microsoft's help says TRIM does not remove it. Use =TRIM(SUBSTITUTE(CLEAN(A1),CHAR(160)," ")) or paste the column here: the rows stay in order.
- How do I remove spaces between letters or between digits?
- Spaced letters turns C H A P T E R O N E into CHAPTER ONE: one space separates letters, two or more separate words. If words are also one space apart, the borders cannot be recovered. Numbers closes up only groups of exactly three digits, 1 250 000.50 to 1250000.50, so phone and card numbers stay; All spaces closes up those too.
- Does a \s regex catch every invisible space?
- No. In JavaScript \s misses U+200B, U+200C, U+200D, U+2060 and U+180E. Python's \s misses those and the byte-order mark U+FEFF. In RE2, which Google Sheets uses, \s means five ASCII characters, so even a non-breaking space gets through. The table above lists all of them with a working pattern below it.
- How do I turn text copied from a PDF into normal paragraphs?
- Choose PDF text. A line break with text on both sides becomes a space, a word hyphenated at a line end is whole again, and blank lines stay. A compound such as well-known keeps its hyphen if the text also has it inside a line. For one line choose One line.
- How do I remove double spaces after a period?
- Extra spaces does it: end.··Next (a dot is a space) becomes end.·Next. The stray space before a mark, 'word , word', is a separate rule, Remove spaces before punctuation. It acts only where the mark ends a word, so .NET, .docx and :) keep their space.
- Can I keep non-breaking spaces?
- Yes. Untick Replace non-breaking and invisible spaces. A single non-breaking space, for example between a number and its unit, then survives every other rule; a run of two or more spaces still becomes one ordinary space.
- Will cleaning invisible characters break emoji or other languages?
- No. Multi-part emoji such as 👩💻 are glued with a zero-width joiner, and a joiner between two emoji is kept. A zero-width non-joiner inside a Persian or Hindi word is spelling and stays; next to Latin letters it is deleted. Direction marks, which Arabic and Hebrew text may need, go only if you tick the rule for them.