Regex Pattern

Remove HTML Tags Regex

By Samrat•Last updated: Nov 2026
Regex Pattern
<[^>]*>

Quick answer

This simple regex matches any HTML tag, allowing you to replace it with an empty string to extract plain text.

🛠️ Fix it right here with AI Regex Generator

Need to modify this pattern or generate a new one? Edit the regex below and let our AI help.

AI suggestions can be wrong. Review and test before applying.

Live Regex Tester

Type a string below to see if it matches this pattern.

How it works

< matches the opening bracket. [^>]* matches any character that is NOT a closing bracket. > matches the closing bracket. This effectively grabs <div>, <p class='x'>, <br/>, etc.

Code Examples

✅ Correct Usage

// JavaScript
const html = "<p>Hello <b>World</b></p>";
const text = html.replace(/<[^>]*>/g, "");
console.log(text); // "Hello World"

❌ What NOT to do

// BAD: Misses tags with line breaks
const badRegex = /<.*>/;

Frequently asked questions

Is it safe to use this for security (XSS prevention)?

NO. Never use regex to sanitize HTML for security. Use a dedicated library like DOMPurify. This is only for simple text extraction.

Related Search Terms

regex remove html tagsstrip html tags regexhtml tag regexregex replace html

Related Regex Patterns

Need a custom regex pattern?

Use the free to describe what you need in plain English.

Want an AI with memory for your project?

MonsterX AI remembers your codebase across chats.