Skip to content

Instantly share code, notes, and snippets.

@sayyedhammadali
Last active October 5, 2021 09:12
Show Gist options
  • Save sayyedhammadali/ed24ca6d9f212c87a10f7867412db3bc to your computer and use it in GitHub Desktop.
Save sayyedhammadali/ed24ca6d9f212c87a10f7867412db3bc to your computer and use it in GitHub Desktop.
Strip HTML From Text
const stripHtml = html => (new DOMParser().parseFromString(html, 'text/html')).body.textContent || '';
stripHtml('<h1>Hello <strong>World</strong>!!!</h1>');
// Result: Hello World!!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment