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 — the <p> and <strong> tags disappear, the words stay. It's the client-side equivalent of PHP's strip_tags() for a quick one-off string, without spinning up PHP or calling an API.

Under the hood it's one regex, input.replace(/<[^>]*>/g, ''), run in your browser — no server round trip. The pattern matches from a < up to the next > and deletes it; that's a textual match, not the structural parsing a browser's DOM does. It's fast and has no dependencies, but it can't tell a real tag from a stray </> pair in ordinary text — a comparison like a < b > c gets read as one tag and removed — and it doesn't specifically strip the contents of <script> or <style> blocks, only the tags wrapping them.

Reach for it when you need to preview how rich text will read once the markup is gone — checking a CMS field, an email template, or scraped HTML for its plain-text content — or before feeding a string into a word/character counter that shouldn't count markup. It's not a sanitizer: because it doesn't strip script/style contents or handle malformed markup safely, don't use it to clean untrusted HTML before rendering it back into a page. For that, use a real HTML parser (DOMParser, textContent) or a dedicated sanitization library.

Examples

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

Output:
Hello world

Every <...> sequence is deleted; the words in between are untouched.

Attributes and entities are unaffectedtext
Input:
<div class="note">Ships in 3&ndash;5 days. <a href="/faq">Read more &raquo;</a></div>

Output:
Ships in 3&ndash;5 days. Read more &raquo;

The class and href attributes vanish with their tags. &ndash; and &raquo; are entities, not tags, so they pass through as-is — decode them separately if you need literal /» characters.

Same regex in JavaScript and PHPjs
// What this tool runs, client-side, on Submit
const text = html.replace(/<[^>]*>/g, '')

PHP equivalent: strip_tags($html). Both leave entities like &amp; undecoded and don't specifically strip the contents of <script>/<style> blocks — only the tags themselves.

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, for example by setting it as an element's innerHTML and reading back its textContent.

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

Functionally, yes — 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 with no allowlist.

Will it break code samples that use < and > as comparison operators?

Yes, this is a known limitation. The tool matches everything from a < up to the next >, so text like a < b > c gets misread as one tag and deleted. It's built for HTML/XML markup, not arbitrary text or source code containing angle brackets.

Does my text get uploaded anywhere?

No. The transform runs entirely in your browser as a single regex — 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?

It removes the tags but not necessarily the text between them — <script>alert(1)</script> becomes alert(1), not an empty string. To drop script or style content entirely, remove those blocks before running this tool.