QuickSnip LogoA light blue logo with a thunderbolt in bracketsQuickSnip

Remove All Whitespace

Removes all whitespace from a string.

  • string
  • whitespace

Install

npx shadcn@latest add https://quicksnip.dev/r/remove-all-whitespace.json

This snippet is not verified yet. Review it before use, or help verify it.

Code

function removeWhitespace(str) {
  return str.replace(/\s+/g, '');
}

Usage

removeWhitespace('Hello world!'); // Returns: 'Helloworld!'