↑↓ to move ↵ to open Esc to close Browse all tools

HTML to Text

Paste HTML or open an .html file to get clean, readable plain text. Scripts, styles and tags are removed, and paragraphs, lists and links stay in place.

Paste HTML code, a whole page or just a part of one, or drop an .html file. The text updates as you type.

Links
Images
Data tables
Headings and style
Words
0
Characters
0
Lines
0
HTML size
0 bytes

Your HTML is converted in your browser. Nothing is uploaded.

Free printableFree Resume TemplateThree clean one-page designs as an editable Word file, with a PDF example. Hand-checked listFree Note-Taking AppsWhat the free plans of 15 note-taking, to-do and knowledge base apps include, with limits and platforms.

HTML to Text by Freebiefy, free online tools · Privacy · Legal notice

Embed this tool on your site

Paste this code into your page. The tool runs in the visitor's browser, free and without signup. The height adjusts to the content. All tools you can embed

What the HTML to text converter does

This tool turns HTML code into plain text you can read, paste into a plain text email, a text field or a document, or feed into another program. It does more than strip the tags: paragraphs and headings are separated by blank lines, list items get a dash or a number, table rows stay on one line each, and links keep their address in brackets if you want. The result shows its word and character count, and you can copy it or download it as a .txt file.

Your HTML is read with the browser's DOMParser into a separate document that is never shown. MDN's page on DOMParser.parseFromString says scripts in such a document are marked as not executable and event handlers are not called. The tool then walks through the elements and writes the text. Character references like & or   are decoded by the parser, so you get the characters, not the codes.

What is removed and why

  • Code and styles: script, style, noscript and template elements. Their content is code or a fallback, not text a reader sees.
  • The head of the page: title, meta and link elements describe the page and do not appear in it.
  • Media and form controls: svg, canvas, video, audio, iframe, object, select, textarea and input elements. Their content is not text for a reader.
  • Hidden content: elements with the hidden attribute or display: none in their style attribute.
  • Comments and all tags and attributes.

Images are written as their alt text in square brackets, like [Garden Club], or left out. An image without alt text is always left out.

How whitespace works in HTML

In HTML source, line breaks and indentation are mostly for the person writing the code. MDN's guide to how whitespace is handled explains the default rules: spaces and tabs around line breaks are dropped, line breaks are turned into spaces, and a run of spaces becomes one space. That is why three spaces between two words in the source show as one space in a browser. The converter follows these rules, so the text reads like the page and not like its source code.

Line breaks in the result come from the structure of the page instead: a blank line around paragraphs, headings, lists, tables, quotes and pre blocks, a single line break around div and other block elements, and one break for each br tag. Text in a pre element keeps its spaces and line breaks as written. Two choices differ from a browser: no-break spaces ( ) become normal spaces, and invisible characters like zero-width spaces are removed, because email templates use long runs of both as padding.

The options

  • Links: Text (URL) writes "garden rules (https://example.com/rules)". Keep the addresses when the text is meant to be read on its own, like a plain text version of a newsletter or notes from a web page, since nobody can click a link in plain text. Choose Text only when you need clean text for word counts, quotes or translation. Links within the page (#top) and javascript: links never show an address.
  • Images: [Alt text] keeps a hint that an image was there. Leave out drops images completely.
  • Data tables: Tab-separated keeps each row on one line with tabs between cells, ready to paste into a spreadsheet. One cell per line is easier to read in a narrow text field.
  • Headings and style: Plain writes headings as normal lines. UPPERCASE makes them stand out in plain text. # Markdown-ish puts # marks before headings, > before quotes, --- for horizontal rules and ``` around pre blocks, so the text is close to Markdown.

Email newsletters

An email can carry the same message twice, as plain text and as HTML. RFC 2046, section 5.1.4 defines this multipart/alternative format: the parts are versions of the same content, ordered from plainest to richest, and the email app shows the richest one it can display. The plain text part is where this converter helps. HTML emails are hard to convert, because most templates are built from nested layout tables, padding characters and hidden preview text. The converter treats a table as layout when it has role="presentation", when its rows have only one cell, or when its cells hold paragraphs, headings, lists or other tables. Layout tables are read like ordinary blocks, and only real data tables get tabs. The hidden preview line is left out. Check the result and shorten the link list by hand if your template has many tracking links.

A worked example

Press Fill in an example to load a short newsletter. Its hidden preview text, style sheet and tracking script disappear. The logo becomes [Garden Club], the heading and paragraphs are separated by blank lines, the nested list is indented by two spaces, and the opening hours table becomes three tab-separated lines. The email link ends as "hello@example.com", without a repeated address, because the link text and the address match.

How to use the HTML to text converter

  1. 1Paste HTML into the box, or drop an .html file on it, or press Open file.
  2. 2Pick how links, images, tables and headings should look.
  3. 3Read the plain text below. It updates as you change the HTML or the options.
  4. 4Copy the text or download it as a .txt file.

To tidy the HTML itself, use the HTML formatter. To turn Markdown into HTML, use Markdown to HTML. For more on the text, the word counter shows reading time and more, and Remove Line Breaks joins lines into one paragraph.

Sources

Frequently asked questions

Is my HTML uploaded anywhere?

No. The HTML is read and converted in your browser, and the text never leaves your device. Copy link only stores the options, never your HTML.

Does the tool run the scripts in my HTML?

No. The HTML is parsed with DOMParser into a separate document that is never shown on the page. MDN notes that scripts in such a document are not run and event handlers are not called. Script and style elements are then left out of the text.

Why are there no extra spaces or line breaks from my code?

Browsers collapse runs of spaces, tabs and line breaks in HTML into one space when they show a page, and the tool follows that rule. Line breaks in the text come from the structure instead: paragraphs, headings, list items, table rows and br tags. Text inside pre elements keeps its spacing.

What happens to links?

With Links set to Text (URL), a link is written as its text with the address in brackets after it, like garden rules (https://example.com/rules). The address is left out when it matches the link text, for links within the page that start with #, and for javascript: links. For mailto: links you get just the email address. Text only drops all addresses.

How are tables converted?

A table with rows and columns of data becomes one line per row with a tab between cells, which you can paste into a spreadsheet, or one cell per line if you pick that. Tables used for page layout, as in most email templates, are read like normal blocks of text, so their content does not end up as one long tab-separated line.

Why is some text from my email missing?

Text hidden with the hidden attribute or with display: none in a style attribute is left out. Newsletters often use such hidden text for the preview line that inboxes show next to the subject. Text that only a style sheet hides, through a class, is kept, because the tool does not apply CSS.