W3docs

String Functions

HTML Tags Remover

Strip HTML tags from any string. Leaves text content and entities intact — useful for previewing rendered text.

About the HTML Tags Remover

HTML Tags Remover strips markup out of a string and leaves the surrounding text and entities untouched. Feed it <p>Hello <strong>world</strong></p> and it returns Hello world. It's the client-side counterpart of PHP's strip_tags() for a quick one-off string, without spinning up PHP or calling an API. Nothing is sent to a server.

It uses a small scanner rather than a single regex. A < only starts a tag when it is followed by a letter, /, ! or ?, so text like a < b and c > d comes through unchanged. A > inside a quoted attribute value (<a href="x>y">) does not end the tag. The contents of <script> and <style> elements are removed along with their tags, and HTML comments are dropped. A tag that never closes is left as literal text rather than deleting the rest of your input.

Reach for it to preview how rich text reads without markup — checking a CMS field, an email template, or scraped HTML — or before feeding a string to a word counter. It is not a sanitizer: it does not decode entities or validate markup, so don't use it to clean untrusted HTML before rendering it back into a page. Use a real HTML parser (DOMParser) or a dedicated sanitization library for that.

Examples

Strip tags, keep the texttext
Input:
<p>Hello <strong>world</strong></p>

Output:
Hello world

Every tag is deleted; the words in between are untouched.

Comparisons, quoted attributes, scripts and commentstext
a < b and c > d                      →  a < b and c > d
<a href="x>y">link</a>               →  link
Hi<script>alert(1)</script>there     →  Hithere
A<!-- note -->B                      →  AB

A < followed by a space or digit is text, a quoted > stays inside its tag, and script/style bodies and comments are removed entirely.

The DOM alternativejs
// Browser-native alternative that also decodes entities
const doc = new DOMParser().parseFromString(html, 'text/html');
const text = doc.body.textContent;

PHP's equivalent is strip_tags($html). Neither this tool nor strip_tags() decodes entities such as &amp;.

Frequently asked questions

Does the HTML Tags Remover decode entities like &amp; or &nbsp;?

No. It only deletes tag markup — anything shaped like &name; or &#123; passes through unchanged. To decode entities too, parse the string as HTML and read back its textContent.

Is this the same as PHP's strip_tags()?

Close for typical input — both remove markup and leave entities alone. One difference: PHP's strip_tags() accepts a second argument listing tags to keep; this tool always strips every tag.

Will it break text that uses < and > as comparison operators?

No. A < only starts a tag when it is directly followed by a letter, /, ! or ?, so a < b and c > d and 1<2 are left as they are. A comparison written like if a<b would still look like a tag start, and is only removed when a closing > follows.

Does my text get uploaded anywhere?

No. The transform runs entirely in your browser — nothing is sent to a server, so it's safe to paste private or sensitive content.

Does it strip <script> and <style> blocks completely, including their content?

Yes. <script>alert(1)</script> becomes an empty string, as does a <style> block and its CSS. HTML comments are removed too.