Skip to content
Aarrange

HTML to Text

Paste HTML: a web page, an email or a snippet. Get plain text with paragraphs, list items and links kept. Nothing leaves your browser.

Also: Clean HTML, Word to HTML

0
Size in
0
Size out
0
Removed
Input
Tab types a tab. Press Escape, then Tab, to leave the editor.
Result
The result shows here as you type.Try , or .
On this page

About HTML to Text

Updated

HTML to Text strips the tags from HTML and gives you the text a reader sees. Use it to make the plain text part of an HTML email, to put web copy into a spreadsheet, or to read the words of a page without its code.

The text keeps the shape of the page. Each paragraph and heading is its own block, each list item its own line, and a <br> is a line break. Entities such as &amp; and &nbsp; turn back into characters. The code inside <script> and <style> goes with its tags, so no CSS or JavaScript ends up in your text.

The tool reads the HTML with a full HTML parser, the way a browser does. A tag that is never closed, or a > inside an attribute, does not break the text.

The same tool, set up for other jobs: HTML Cleaner and Word to HTML. To indent HTML that is already clean, use the HTML Formatter. To check it against the HTML standard, use the HTML Validator.

How to use it

  1. Paste HTML into the editor: a web page, an email, a snippet from a CMS. Or open an .html file. You can also copy text from a web page, Word or Google Docs and press Ctrl V (⌘V on a Mac): the editor gets the HTML behind it.
  2. The Plain text view shows the text at once, with a blank line between paragraphs, one line per list item and the links where you choose. The text is made from the clean HTML, so scripts, styles and hidden text never get into it.
  3. Open Options to choose what to keep. For the text: Text links (the address after the link text, or left out), Text bullets on list items, and a Text width to wrap at.
  4. Switch views in the Result pane: HTML, Page (the result as a page), Changes (every change, with a count and the lines; a line number takes you there), Plain text, Markdown, Summary and Notes (each change and each thing to fix, by line). Things you must fix by hand, such as an image that points to a file on your PC, come first in Changes.
  5. Press Copy or Download in the Result pane. HTML, Plain text and Markdown each copy their own text. On Page, Changes, Summary and Notes, Copy and Download take the clean HTML.

HTML to text, before and after

Links inline, one line per item

The text keeps the shape of the page: a blank line between paragraphs, one line per list item, and a line break where the HTML has <br>. By default each link address follows its text in brackets, so nothing is lost. Set Text links to Leave out for the words only.

HTML
<h2>Launch checklist</h2>
<p>See the <a href="https://example.com/plan">launch plan</a>.</p>
<ul><li>Security review</li><li>Load test</li></ul>
<p>Owner: Sam<br>Due: Friday</p>
Plain text
Launch checklist

See the launch plan (https://example.com/plan).

- Security review
- Load test

Owner: Sam
Due: Friday

Why a regex is not enough

The usual one-liner, replace(/<[^>]*>/g, ""), removes the tags and nothing else. Words from two paragraphs run together, entities stay as &amp;, and the code inside <script> and <style> stays in the text. A > inside an attribute cuts a tag in half.

HTML
<style>p { color: red }</style>
<p>Tom &amp; Jerry</p><p>Season 2</p>
Regex result
p { color: red }
Tom &amp; JerrySeason 2
This tool
Tom & Jerry

Season 2

Plain text for an HTML email

Most email tools let you add a plain text part next to the HTML. Some readers and some spam filters look for it. Paste the HTML of the email here, keep Text links on Address after the text, and set Text width to 72 or 78 characters, the line length email programs expect.

HTML email
<td><p>Hi Sam,</p><p>Your order <b>#10482</b> has shipped.
<a href="https://example.com/track/10482">Track it here</a>.</p></td>
Plain text
Hi Sam,

Your order #10482 has shipped. Track it here
(https://example.com/track/10482).

HTML to Text resources

  • MDN: Node.textContentThe text of an element and all its children, with no tags. Fast, but it joins block elements with no line break.
  • MDN: HTMLElement.innerTextThe text as the page shows it, with line breaks. It needs a rendered page, so it does not work in Node or a worker.
  • html-to-text for Node.jsA Node library that turns HTML into plain text, with word wrap, tables and link options. For HTML to text in a script.
  • Beautiful Soup documentationHTML to text in Python: soup.get_text("\n", strip=True) gives the text with a line break between blocks.
  • HTML Standard: Parsing HTML documentsThe rules every browser uses to read broken HTML. The cleaner reads your HTML by the same rules, so an unclosed tag ends where a browser ends it.
  • OWASP: Cross Site Scripting PreventionWhy script tags, on* handlers and javascript: links in pasted HTML are a risk, and how sites defend against them.

HTML to Text FAQ

What does it mean to strip HTML?

To strip HTML is to remove every tag and keep only the text a reader sees. <p>Hello <b>world</b></p> becomes Hello world. A good HTML stripper also removes the code inside <script> and <style>, turns entities such as &amp; back into &, and keeps a line break where one block ends and the next starts.

How do I remove HTML code from text?

Paste the text with the HTML into the editor on this page. The Plain text view shows the text at once. Press Copy or Download in the Result pane to take it.

Why is my HTML showing up as text?

Because the place you pasted it shows text, not HTML. A plain text field, an email in plain text mode, or a CMS field that escapes < as &lt; shows the tags as they are. Either paste it where HTML is read (the code or HTML view of the editor), or turn it into plain text here first.

How do I convert HTML to text in JavaScript?

In a browser, put the HTML in a new element and read its text: const d = document.createElement("div"); d.innerHTML = html; then d.textContent. That joins blocks with no line break. innerText keeps the breaks, but only on a page that is shown. In Node, use the html-to-text package. Never put HTML you do not trust into innerHTML on a live page.

How do I convert HTML to text in Python?

With Beautiful Soup: BeautifulSoup(html, "html.parser").get_text("\n", strip=True). The first argument puts a line break between pieces of text. Remove script and style tags first with tag.decompose(), or their contents end up in the text.

Can I keep the links when I strip HTML?

Yes, they are kept by default: each link address follows its text in brackets, as in launch plan (https://example.com/plan). A link whose text is its own address shows once. To keep only the words, set Text links to Leave out under Options.

Is there a size limit?

There is no size limit. A text of 100,000 characters or more is cleaned in a background worker, so the page does not freeze while it works. A 5 MB Word export cleans in about 2 seconds on a laptop.

Is my HTML sent anywhere?

No. The HTML is cleaned in your browser, and a .docx file is read in your browser too. Nothing is uploaded, there are no ads over the editor and no daily limit. You can check this in your browser's network tab while you use it.