Strip HTML tags

JavaScript, String, Regexp · Sep 15, 2020

Removes HTML/XML tags from string.

  • Use a regular expression to remove HTML/XML tags from a string.
const stripHTMLTags = str => str.replace(/<[^>]*>/g, '');
stripHTMLTags('<p><em>lorem</em> <strong>ipsum</strong></p>'); // 'lorem ipsum'

More like this

  • Escape HTML

    Escapes a string for use in HTML.

    JavaScript, String · Oct 13, 2021

  • Unescape HTML

    Unescapes escaped HTML characters.

    JavaScript, String · Oct 22, 2020

  • Remove non ASCII characters

    Removes non-printable ASCII characters.

    JavaScript, String · Oct 22, 2020