HTML Tag Remover

Files & data

Strip tags to plain text, and escape or unescape entities.

Plain text
Hello Some markup & an entity.
10 tags removed
Tags removed10
Characters30
Stripping tags is not sanitising. This turns markup into plain text; it does NOT produce markup that is safe to insert into a page. If you are removing HTML for security, use a real sanitiser on the server that owns the output.
Script, style and SVG elements had their CONTENTS removed as well as their tags. Removing only the tags would leave a page of CSS and JavaScript in the middle of the text.

How to use

What it's for

Turn web-page code (HTML) into plain, readable text — from a page's source or an email template, say — or rewrite HTML so a web page shows the code itself as text.

Before you start

Have the HTML ready to paste, and know which job you want: plain text to read or reuse, or code to show as an example.

  1. Paste the HTML

    Paste it into the HTML box, replacing the example. Paragraphs, headings and list items each become a line of their own in the result.

  2. Pick the mode

    In Mode, Remove tags gives plain text and is the usual choice. Escape as entities does the opposite: it keeps the tags but rewrites them, so a web page shows the code as text instead of running it.

  3. Leave Decode entities ticked

    With Remove tags, keep Decode entities ticked so codes such as & turn back into the character they stand for, here &. Untick it only if you need those codes left as they were written.

  4. Show the result and copy it

    Press Remove tags under the box to bring the result into view; it also updates as you type. Then press Copy at the top to take it.

Reading the result

  • Plain text: your text with every tag gone — or Escaped, the code rewritten to show as text, when that is the mode.
  • Tags removed: how many tags were taken out. Characters is the length of the result.
  • A note confirms that the contents of script and style blocks, which are a page's code and styling, went with their tags, so they do not end up in your text.

If it goes wrong

  • Do not use this to make HTML safe to put back on a website: it gives plain text to read, not safe code. A note says so every time.
  • Codes such as & still show in the result: tick Decode entities.
  • Some text you wanted is missing: anything inside a script or style block is removed with it, because it is code rather than text.

What this is

One thing on this page is worth reading: stripping tags is not sanitising. It turns markup into plain text; it does not turn text into markup that is safe to insert into a page. Those are different jobs, and the second needs a real sanitiser on the server.

Block elements become line breaks. Without that, every paragraph runs together into one continuous line — the commonest complaint about tools that do this.

The contents of script and style go too, not just their tags. Removing only the tags leaves CSS and JavaScript sitting in the middle of your text.

And entities are decoded last. Decoding first would turn <script> into a live tag — creating markup out of text that was deliberately escaped.

Questions

Can I use this to make user input safe to display?

No, and this is the one thing worth reading on this page. Stripping tags turns markup into plain text; it does not produce markup that is safe to insert into a page. Those are different jobs and the second one needs a real sanitiser running on the server that owns the output. If you are removing HTML for security reasons, this is the wrong tool.

Why did my paragraphs end up on separate lines?

Because block elements become line breaks. Removing tags without them runs every paragraph, list item and table row together into one continuous line, which is the commonest complaint about tools that do this. Inline elements like span and em do not break.

What happens to script and style contents?

They go entirely, not just their tags. Removing only the tags would leave a page of CSS rules and JavaScript sitting in the middle of your text, which is never what “remove the HTML” means. An unclosed script element takes the rest of the input, which is what a browser does too.

What is the difference between stripping and escaping?

Stripping removes markup so the text reads as text. Escaping converts the markup characters into entities so the text DISPLAYS as markup — useful when you want to show someone a code sample. They are opposite operations and this page does both.

Why does escaping do the ampersand first?

Because every other replacement introduces one. Escape the less-than sign first and you get <, then escaping ampersands turns that into < — the classic double-escape. The ampersand has to go first or the output is wrong in a way that looks almost right.

Why decode entities after stripping rather than before?

Because decoding first would turn <script> into a live tag — creating markup out of text that was deliberately escaped, which is the exact opposite of the job. Decoding happens last, on what is left.

The maths

The order
1. Script, style, SVGcontents as well
2. Commentsentirely
3. Block elementsbecome line breaks
4. Every remaining tagremoved
5. Entitiesdecoded last

Repeated until nothing more is found. <scr<script>ipt> leaves a live tag behind when the pattern runs only once.

The ampersand goes first

When escaping, the ampersand is replaced first. Do < first and the &lt; it produces becomes &amp;lt; — the classic double-escape.

Keep going

Important

Runs entirely in your browser. Stripping tags is not sanitising — this produces plain text from markup, not markup that is safe to insert into a page. For security, use a real sanitiser on the server that owns the output. Nothing you type here is sent to our servers — the calculation runs entirely in your browser.