How to strip whitespace from text

Paste or type the text, press Remove all whitespace, and every character that JavaScript counts as whitespace is deleted inside the page: spaces, tabs, line breaks and the other space characters listed below. Nothing is uploaded and no file is downloaded.

The result opens in the panel under the buttons. Copy puts the plain text on the clipboard, not the coloured markup around it.

  1. Paste or type the text into the box at the top of the page.
  2. Press Remove all whitespace. The matching characters disappear immediately, with no upload and no second request.
  3. Read the result in the panel under the buttons, and press Copy to take the text without the highlighting.
  4. Press Clear to empty the box and hide the result before the next run.

What is removed and what the result is not

What counts as whitespace

The rule is the JavaScript \s class applied globally: the space, tab, line feed, carriage return, form feed and vertical tab, plus the non-breaking space (U+00A0), U+1680, U+2000-U+200A, the line and paragraph separators (U+2028 and U+2029), U+202F, U+205F, the ideographic space (U+3000) and the byte order mark (U+FEFF).

Characters outside that class stay where they are. Measured on the page: text holding a non-breaking space, an ideographic space, a zero-width space, a zero-width non-joiner and a byte order mark comes back without the first two and without the mark, while the zero-width space and the zero-width non-joiner survive, so a result that looks empty can still carry invisible characters.

The result is not a minifier

The text is handled as characters, never as code, JSON, HTML or a query string, so whitespace inside a quoted string, inside an HTML attribute or between JSON tokens is deleted exactly like the indentation around it: a b becomes ab, and <a href="x y"> becomes <ahref="xy">.

Nothing is parsed, re-indented, re-wrapped or validated afterwards. Where the whitespace carries meaning - indentation-sensitive languages, Markdown, prose - treat the output as raw material for a formatter or minifier that understands the syntax.

Practical notes

An empty box, or text that is nothing but whitespace, opens the result panel with nothing in it. Results up to 50,000 characters are coloured with highlight.js for common languages; longer results, and text that matches none of those languages, are shown as escaped plain text - the same characters without colours, which keeps the page responsive.

Everything runs in the browser tab: your text is not sent anywhere, and the tool keeps working after the page has loaded even without a network connection.

Recent tools: