Last active
October 5, 2021 09:12
-
-
Save sayyedhammadali/ed24ca6d9f212c87a10f7867412db3bc to your computer and use it in GitHub Desktop.
Strip HTML From Text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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