Skip to Content
  • Website
Codsen
  • Home
  • Open Source
  • Articles
  • About

Stripping HTML

by Roy Revelt   ·   posted on Sunday, 17 July 2022   ·   a thought

Mr Toh posted a good articleopens in a new tab comparing various means to strip tags from HTML, including our npm package string-strip-html.

To add 2p.

It’s not just about speed.

The primary reason why you’d use an npm package, rather than regex, is whitespace management. The string-strip-html ensures the stripped results looks as if a human deleted the tags. Our program can even be used to generate email text versions, placing URLs besides the stripped link labels.

The second reason is string-strip-html can tackle broken HTML, dirty HTML and HTML mixed with other languages.

The third reason is string-strip-html saves you time: writing unit tests, writing correct type definitions (you’re using TypeScript, right?) and tackling edge cases.

↑ back to top
older newer

Copyright

All rights reserved © Roy Revelt 2026
All our open source packages are under MIT licenceopens in a new tab

Activities

🐛 See a bug? Raise an issueopens in a new tab
💘 Check out the Indiewebopens in a new tab and Libera manifestoopens in a new tab