Remove all whitespace from text

Remove all whitespace from text by stripping every space, tab, and newline in one pass, or pick a narrower mode to target only spaces, only tabs, or only line breaks. Custom mode lets you list your own characters to remove. The Replace With field substitutes each match instead of deleting it. The transform runs in your browser. To collapse runs without deleting them, use remove extra spaces instead.

Input
Line 1:1 LF cloud_done Saved locally
Result Remove All Whitespace
0 lines 0 chars

How whitespace removal works

The default mode All Whitespace uses the regex /\s+/g, which matches every Unicode whitespace character including ASCII space, tab, newline, carriage return, non-breaking space, em space, and the rest of the White_Space property. Each run of one or more whitespace characters is replaced by the value in the Replace With field, which defaults to an empty string for full removal.

Three narrower modes target one kind of whitespace at a time. Spaces Only matches only the ASCII space character. Tabs Only matches only the tab character. Newlines Only matches \n or \r\n. Each is implemented with a tighter regex, so non-target whitespace passes through. Useful when you want to flatten paragraphs but keep tabs aligned, or strip tabs without losing line breaks.

The fifth mode, Custom, takes any characters you type into the Custom field and matches them as a character class. Each character is regex-escaped so dots, brackets, and slashes work as literals. The Replace With field still applies, so you can swap your custom characters for a hyphen or any other string. Output is computed in your browser on every keystroke, no upload.

How to use remove all whitespace from text

  1. 1Paste text into the input panel on the left.
  2. 2Pick a Mode: All, Spaces Only, Tabs Only, Newlines Only, or Custom.
  3. 3For Custom, type the characters you want stripped into the Custom field.
  4. 4Optionally fill Replace With to substitute each match instead of deleting it.
  5. 5Click Copy to grab the cleaned text.

Keyboard shortcuts

Drive TextResult without touching the mouse.

Shortcut Action
Ctrl FOpen the find & replace panel inside the input Plus
Ctrl ZUndo the last input change
Ctrl Shift ZRedo
Ctrl Shift EnterToggle fullscreen focus on the editor Plus
EscClose find & replace, or exit fullscreen
Ctrl KOpen the command palette to jump to any tool Plus
Ctrl SSave current workflow draft Plus
Ctrl PRun a saved workflow Plus

What this tool actually does

All-whitespace mode catches every kind

The default uses /\s+/g, which matches the full Unicode White_Space set: ASCII space, tab, line feed, carriage return, vertical tab, form feed, non-breaking space, em space, en space, and others. Each run collapses into the replacement string, default empty.

Narrow modes for targeted strips

Pick Spaces Only for ASCII space, Tabs Only for tab, or Newlines Only for \n or \r\n. Other whitespace passes through. Lets you flatten paragraphs without breaking column alignment, or remove tabs without joining lines.

Custom mode takes your own character set

Switch Mode to Custom and type any characters into the Custom field. Special regex characters are escaped automatically, so ., (, [, \, and others are matched literally. The match is greedy: a run of any characters in your set is treated as one match.

Replace With substitutes instead of deletes

The Replace With field is the second argument to the regex replacement. Empty (default) deletes the matched whitespace. A single space turns runs of mixed whitespace into single spaces. A hyphen joins words, useful for slug-style output.

Greedy match keeps the result tidy

Each regex uses the + quantifier, so consecutive whitespace characters collapse into a single match. With Replace With set to a single character, runs of 5 spaces and a tab become exactly one replacement character, not five.

Worked example

Mode: All Whitespace, Replace With empty. Every space, tab, and newline disappears in one pass.

Input
  hello   world  
	tab	here
Output
helloworldtabhere

Settings reference

Setting or behaviour Effect on output
Mode: All Whitespace (default) Strips every Unicode whitespace character via /\s+/g.
Mode: Spaces Only Strips only ASCII space. Tabs and newlines pass through.
Mode: Tabs Only Strips only tab characters.
Mode: Newlines Only Strips \n and \r\n. Spaces and tabs pass through.
Mode: Custom Strips any characters listed in the Custom field. Regex specials are auto-escaped.
Custom field Active only when Mode is Custom. Empty custom = no-op pass-through.
Replace With field Substitutes each match. Default empty = full deletion. Single space = whitespace normalisation.
Letters, digits, punctuation, emoji All pass through unchanged in every mode.

FAQ

How do I just remove tabs without losing newlines?
Set Mode to Tabs Only. The pass strips only tab characters; spaces and newlines stay where they were. Set Replace With to a single space if you want columns separated by space instead of nothing.
What is the difference between this and remove extra spaces?
This tool deletes whitespace; remove extra spaces only collapses runs of spaces. Use this when you want every space gone (slug-style or fingerprint-style output). Use the other when you want a tidy, readable paragraph.
How does Custom mode handle special characters?
Each character in the Custom field is escaped before being placed inside a character class, so dots, brackets, slashes, and parentheses are matched literally. To strip every · and _, type both into the field. There is no need to quote or escape anything yourself.
Can I replace whitespace with a hyphen for slugs?
Yes. Set Mode to All Whitespace and Replace With to -. Every run of whitespace becomes a single hyphen, producing slug-style output. For full slug generation including case folding, use slug generator.
Does it touch non-breaking spaces?
Yes, in All-Whitespace mode. The Unicode \s class includes U+00A0 (non-breaking space), so they get stripped along with regular spaces. In Spaces Only mode, non-breaking spaces pass through, since that mode targets only the ASCII space character.