Menu

Remove HTML Tags from Text

Paste HTML and get plain text back. Every tag is removed, script and style code is dropped, paragraphs, headings and list items stay on their own lines, and entities such as & turn back into characters.

0 words 0 characters 0 lines

Continue with this text: Remove extra spacesRemove empty linesHTML entities

Your text stays in your browser: nothing is uploaded or stored on a server.

How to strip HTML tags

  1. Paste the HTML into the input box, click Open file to load an .html, .htm or .txt file, or click Example to see a sample.
  2. Leave Keep line breaks from <p>, <br>, <li> and headings ticked if the text should keep its paragraphs and list items on separate lines.
  3. Leave Decode entities ticked to turn &amp;, &nbsp;, &ndash; and similar codes back into characters.
  4. The plain text appears as you type. Click Copy, Download .txt, or Use as input to run another tool on it, such as remove extra spaces.

What the tool removes, step by step

The tool works on the HTML as text, in this order:

  1. Code blocks are deleted with their contents. Everything between <script> and </script> goes, and the same for <style>, <noscript> and <template>. That keeps JavaScript and CSS out of your text. HTML comments (<!-- ... -->) are removed too. Tag names are matched in any case, so <SCRIPT> is treated the same as <script>. If the closing tag is missing (a cut-off paste), everything from the opening tag to the end of the text is removed.
  2. Source whitespace is collapsed when the HTML contains layout tags (<p>, <br>, <div>, <li>, headings, lists, tables, <blockquote>, <section>, <article>). As in a browser, every run of spaces, tabs and line breaks in the source becomes one space, except inside <pre>. Text without any of these tags keeps its own line breaks and spacing.
  3. Line breaks are added. With the first option on, each <br> and the end of each block (</p>, </div>, </li>, </h1> to </h6>, </title>, </tr>, </ul>, </ol>, </table>, </blockquote>, </section>, </article>, </pre> and similar) becomes a line break, and the end of each table cell (</td>, </th>) a tab. Block ends that follow each other with only spaces or tags between them, such as </li></ul><p>, give one line break, not several. With the option off, each of these becomes one space, together with any spaces around it.
  4. Every remaining tag is removed. A tag starts with < followed by a letter, /, ! or ?, and ends at the next > that is not inside a quoted attribute value: <b>, <span class="x">, <a href="...">, <img>, <!DOCTYPE html>. A < followed by anything else, such as a space or a digit, is kept as text.
  5. Entities are decoded (if the second option is on). This runs after the tags are gone, so an encoded tag such as &lt;b&gt; becomes the visible text <b> and is not removed.
  6. Whitespace is tidied. When source whitespace was collapsed, spaces at the start of each line are removed. Spaces and tabs at the end of each line are always removed, three or more line breaks in a row become one empty line, and the whole result is trimmed at the start and end.

Indentation and line breaks inside <pre> blocks are kept as they were.

The two options

Option On (default) Off
Keep line breaks from <p>, <br>, <li> and headings Each paragraph, heading, list item and <br> ends a line; table cells are separated by a tab Each of these becomes a space, so <p>One</p><p>Two</p> gives One Two and words never merge
Decode entities Fish &amp; chips → Fish & chips Entities stay as written: Fish &amp; chips

Turn line breaks off when you want one continuous line, for example for a meta description or a single spreadsheet cell. HTML without layout tags keeps the line breaks typed in its source, whichever setting you choose. With the option off, the spaces around a block end are merged too, so <p>a</p>, a new line, <p>b</p> gives a b with a single space, and the built-in example gives Opening hours We are open Monday to Friday, 9–5. Café & shop Library. Turn decoding off when the text goes back into an HTML page or a system that expects encoded characters.

Worked examples

The built-in example, with both options on:

<h2>Opening hours</h2>
<p>We are open <strong>Monday&nbsp;to&nbsp;Friday</strong>, 9&ndash;5.</p>
<ul><li>Café &amp; shop</li><li>Library</li></ul>
<script>track();</script>

becomes:

Opening hours
We are open Monday to Friday, 9–5.
Café & shop
Library

The line breaks in the source are collapsed, so each line comes from a closing </h2>, </p> or </li>. The <script> line is gone completely.

Single fragments:

Before After
<p>Hello <b>world</b></p> Hello world
Line one<br>Line two<br/>Line three Line one / Line two / Line three (three lines)
Click <a href='x'>here</a>. Click here.
<img src="a.png" alt="Logo">Text Text
<!-- note -->Visible Visible
Price &euro;5 &#8364;5 &#x20AC;5 Price €5 €5 €5
<p>&lt;b&gt; means bold</p> <b> means bold
<table><tr><td>A</td><td>B</td></tr><tr><td>C</td><td>D</td></tr></table> A⇥B / C⇥D (two lines, ⇥ = tab)
x < 5 and y > 3 x < 5 and y > 3
<div title="a > b">Text</div> Text
<ul>, <li>One</li>, <li>Two</li>, </ul> on four source lines One / Two (two lines)
<ul><li>A</li></ul><p>B</p> A / B (two lines, no empty line)

Edge cases to check

  • Tables. Each row ends a line and cells are separated by a tab, so <td>Name</td><td>Email</td> gives Name, a tab, Email. Pasted into a spreadsheet, the tabs put each cell in its own column.
  • A less-than sign followed by a letter. x < 5 is kept, but if a<b and c>d becomes if ad, because <b and c> has the shape of a tag (a browser reads it the same way). An email address in angle brackets is removed too: email <[email protected]> becomes email. Encode these as &lt; in the source or check them after stripping.
  • Unclosed scripts. If a cut-off paste contains <script> without </script>, everything from <script> to the end of the text is removed, so check that no real text followed it.
  • No-break spaces. &nbsp; decodes to a no-break space (U+00A0), which looks like a normal space but is a different character. Find-and-replace on spaces may skip it; the invisible characters tool finds and replaces it.
  • Page titles and alt text. The text inside <title> is kept on its own line before the body text. Image alt text is removed with the <img> tag.

When people need it

  • Copying from a CMS or email builder. Exported blog posts, product descriptions and newsletter templates arrive full of <p>, <span style> and &nbsp;. Strip them to get text for a plain-text email, a press release or a word count.
  • Cleaning a spreadsheet column. Product feeds and CRM exports often put HTML descriptions in a cell. Paste the column here, strip it, and paste the plain text back. With line breaks kept, a cell with several paragraphs becomes several lines, so join them with remove line breaks if each cell must stay on one line.
  • Preparing text for a database or API field that accepts plain text only, such as an app store description or a meta description.
  • Reading the text of a saved web page without opening it in a browser, by loading the .html file with Open file.

After stripping, the usual next steps are removing extra spaces left over from plain-text indentation and removing empty lines if you want the text without any gaps.

Questions

Is my HTML uploaded anywhere?

No. The tags are removed by JavaScript in your browser, so the HTML never leaves your device. That makes it safe for email templates, CMS exports and internal pages.

Does it keep the link addresses?

No. The link text stays and the "href" address is removed with the tag, so a link to https://example.com that reads Example becomes just "Example". If you need the addresses, run the HTML through the URL extractor first.

Why is there no blank line between my paragraphs?

Each closing "</p>" ends one line, and line breaks in the HTML source are collapsed as a browser does, so paragraphs come out on consecutive lines. A run of closing tags such as "</li></ul><p>" also gives a single break. An empty line appears only where a "<br>" adds a break of its own, for example "<br>" between two paragraphs or "<br><br>" inside one. Leftover empty lines can be deleted with the remove empty lines tool.

Can I remove HTML tags in Excel?

Yes, with Find and Replace: select the column, press Ctrl+H, type "<>" in Find what, leave Replace with empty and click Replace All. The "" wildcard matches any characters, so everything from "<" to the next ">" is removed. Excel does not decode entities such as "&amp;", so for cells with entities paste the column here instead.

How do I convert HTML to text in Power Automate?

Microsoft's Content Conversion connector has an action called Html to text that converts an HTML document to plain text. Microsoft documents that it removes hyperlinks, uppercases headings and wraps lines at 80 characters, so its output differs from this tool's.

Why did some of my text disappear?

A "<" followed by a letter, "/", "!" or "?" starts a tag, as in a browser. So "x < 5 and y > 3" is kept, but "if a<b and c>d" becomes "if ad" and an email address written as "<[email protected]>" is removed like a tag. Check angle-bracket addresses after stripping.

Does it decode every HTML entity?

It decodes every named entity in the HTML standard that ends with a semicolon ("&amp;", "&nbsp;", "&eacute;", "&hearts;"...) and all numeric ones ("&#8364;", "&#x20AC;"). Names are case-sensitive, and an unknown name, or a name without its semicolon, is left as written; the HTML entities tool uses the same rules.