Remove Whitespace
TX-53Paste text and delete every space, tab and line break, or only the spaces and tabs, or just the whitespace at the start and end of each line.
Runs in your browser. Nothing is uploaded.
Text
Text without whitespace
How to use it
- Paste your text into the input box.
- Tick Also remove zero-width characters if the text may hold invisible ones.
- Press Remove all whitespace to delete spaces, tabs and line breaks, so everything runs together.
- Or press Remove spaces and tabs only to keep the line breaks, or Trim each line to keep the spaces between words.
Which characters count as whitespace
Whitespace follows the JavaScript definition: the space, tab, line feed, carriage return, form feed, vertical tab, the non-breaking space, the other Unicode space separators and the byte order mark. Remove all whitespace deletes every one of them, which is the right choice for a code, a token or a number that was split with spaces. The words in ordinary text will run together, so it is rarely what you want for sentences.
Three ways to remove it
Remove spaces and tabs only deletes everything except line breaks, so the line structure stays. Trim each line removes whitespace only at the start and end of every line and leaves the spaces between words alone. If what you need is to squeeze repeated spaces into one without removing them all, use the Remove Extra Spaces tool. To delete line breaks and keep the spaces, use Remove Line Breaks.
Invisible characters
Zero-width characters are not whitespace in Unicode, so they stay unless you tick the option. It removes U+200B, U+200C, U+200D and U+2060. Removing U+200D can split an emoji that is built from several emoji, and U+200C matters in some scripts such as Persian, so tick it only when you need to. Text copied from web pages and chat apps is the usual source of these hidden characters.
Error messages and what to do
| Message | What it means | Fix |
|---|---|---|
Paste the text to strip. | The input box is empty. | Paste or type the text first. |
Questions people ask
How do I remove all whitespace from a string?
Paste the string and press Remove all whitespace. Spaces, tabs, line breaks and non-breaking spaces are deleted and the characters between them are joined together.
How do I remove spaces but keep the line breaks?
Press Remove spaces and tabs only. Every space, tab and similar space character is removed and each line break stays, so the text keeps its lines.
How do I remove leading and trailing spaces from each line?
Press Trim each line. It removes whitespace at the start and end of every line and leaves the spaces between words, and the line breaks, unchanged.
Does it remove non-breaking spaces?
Yes. The non-breaking space, U+00A0, counts as whitespace and is deleted by both the Remove all whitespace and the Remove spaces and tabs only actions. Zero-width characters need the extra option to be removed.
Why does my text still look spaced after removing whitespace?
It probably holds zero-width or other invisible characters that are not classed as whitespace. Tick Also remove zero-width characters and run the action again; the usual source is text copied from web pages.
About this tool
Whitespace follows the JavaScript definition: space, tab, line breaks, form feed, vertical tab, the non-breaking space and the other Unicode space separators, and the byte order mark. Remove all whitespace deletes every one of them, line breaks included, so words run together. Remove spaces and tabs only deletes everything except line breaks. Trim each line removes whitespace only at the start and end of each line and keeps the space between words. Zero-width characters are not whitespace in Unicode, so they stay unless you tick the option; removing U+200D can split an emoji sequence into separate emoji. If you only want to squeeze repeated spaces to one, use Remove Extra Spaces. Nothing is uploaded.