Remove HTML Tags
Parse HTML with the browser DOMParser and return only body.textContent, effectively removing markup.
How to use
- Enter HTML and run to inspect the resulting plain text.
Capabilities and scope
Instead of deleting angle-bracket patterns with regex, it reads text from the DOM produced by the browser HTML parser.
How it works
It returns new DOMParser().parseFromString(input,'text/html').body.textContent.
Example
<p>Hello <b>world</b></p> becomes the text Hello world.
Useful for
- Get text content from an HTML fragment without tags
Before you use it
- Visual layout line breaks are not reproduced and the result follows DOM textContent semantics, including content from parsed nodes.
Frequently asked questions
What happens to HTML entities?
DOMParser decodes entities such as & into their text characters.