How to use the html tag remover
- Paste or type your HTML markup into the HTML input box.
- Check Preserve block spacing if you want line breaks between paragraphs, headings and other block elements.
- The plain text result updates automatically as you type.
- Copy the output for use in documents, emails or other tools.
How the tokenizer works
A naive approach to stripping tags uses a regular expression like /<[^>]*>/g, but that fails on attributes containing angle brackets, unclosed quotes or raw text inside script and style elements. This html tag remover instead reads the input character by character using a small state machine.
When it encounters <, it checks what follows. If the next characters form !--, it enters a comment state and consumes everything until -->. If they form ! followed by letters, it treats the sequence as a doctype declaration. For <script or <style, it switches to a raw-text state where nothing is emitted until the matching closing tag appears. All other tags are parsed through an attribute-aware loop that correctly handles quoted strings, meaning an attribute value like data-x="a > b" will not prematurely end the tag.
Entity decoding reference
After tags are removed, the remaining text may still contain HTML character references. The tool decodes named entities, decimal references like A and hexadecimal references like A. Here are some common named entities and their decoded values:
| Entity | Character | Description |
|---|---|---|
& | & | Ampersand |
< | < | Less than |
> | > | Greater than |
" | " | Double quote |
' | ' | Apostrophe |
| Non-breaking space | |
© | © | Copyright sign |
€ | € | Euro sign |
Block-level spacing
When you enable Preserve block spacing, the tool inserts double line breaks before and after block-level elements such as p, div, h1 through h6, ul, ol, li, blockquote, pre, table, tr, section, article, header, footer, nav, aside, figure, figcaption, address, hr and br. Void elements like br and hr produce a single line break, and table cells (td, th) and definition terms (dt, dd) are separated by a space so neighbouring cells do not run together. In this mode each line is also trimmed, which removes the indentation inside pre blocks. After processing, consecutive blank lines are collapsed so the output stays compact. If you disable this option, all tags are simply removed and the remaining text nodes are concatenated directly, which is useful when you need a single continuous string.
Practical use cases
Stripping markup is a common step in data cleaning. When extracting text from web pages for analysis, leftover tags can corrupt word counts or search indexes. An html tag remover cleans the content before it reaches a word counter or a natural-language pipeline.
Another scenario is preparing database content for plain-text emails. Rich text stored as HTML needs its tags removed while keeping the readable words intact. If you need structured conversion rather than plain text, sibling tools handle specific formats: use html to markdown for Markdown output, or html table to csv when you only need tabular data extracted.
Common edge cases handled
Several patterns trip up simple regex-based strippers. Unclosed tags like <p at the end of a file are treated as literal text because no closing > is found. Attributes with embedded angle brackets, such as <div title="a > b">, are parsed correctly because the tokenizer respects single and double quotes inside tags.
Nested script tags are another edge case. The raw-text consumer looks specifically for </script> (case-insensitive) and ignores any < characters inside the script body. Similarly, malformed comments like <!-- -- --> are consumed up to the first valid --> sequence. Numeric character references outside the valid Unicode range are left unchanged, and references to zero or to surrogate code points become the replacement character. Named entities that are not in the built-in list (the common punctuation, symbol, arrow and Latin-1 names such as eacute and times) are left as written.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple paragraph | HTML input: <p>Hello <strong>world</strong>!</p>; Preserve block spacing: no | Hello world! |
| Page with script and style | HTML input: <!DOCTYPE html><html><head><style>body{color:red}</style></head><body><h1>Title</h1><script>alert('hi')</script><p>Text</p></body></html>; Preserve block spacing: yes | Title / Text |
| Entities and comments | HTML input: <!-- hidden --><div>Price: €50 & tax < 10%</div>; Preserve block spacing: yes | Price: €50 & tax < 10% |
FAQ
Does this html tag remover work offline?
Yes. The entire tokenizer is written in plain JavaScript and runs locally in your browser. No network requests are made and no HTML is sent to a server.
Will it remove script and style content?
Yes. The tokenizer detects script and style opening tags and skips everything inside them until the corresponding closing tag, so executable code and CSS rules never appear in the output.
Are HTML comments stripped too?
Comments starting with are fully consumed and omitted from the plain text result.
What happens to character entities like & or ©?
Named entities, decimal numeric references and hexadecimal numeric references are decoded into their corresponding Unicode characters.
Can I keep line breaks between paragraphs?
Enable the Preserve block spacing checkbox. The tool inserts newlines around block-level elements like p, div, h1 and li, then collapses multiple blank lines into one.
Is this the same as converting HTML to Markdown?
No. This tool removes all markup and returns only text. If you need formatting preserved as Markdown syntax, use a dedicated html to markdown converter instead.