Xerobit

HTML to Text Converter

Paste any HTML markup into this tool to convert it to clean plain text. It strips tags, decodes character entities, formats block elements with line breaks, adds bullets to lists and optionally preserves link URLs. Everything runs locally in your browser so nothing is uploaded to a server.

Plain text

How to use the html to text converter

  1. Paste your HTML markup into the HTML input text area.
  2. Check Show link URLs if you want anchor hrefs appended after their text.
  3. The plain text result updates automatically as you type or paste.
  4. Copy the output for use in emails, documents or other tools.

How the conversion works

This converter uses a hand-written tokenizer that reads through the HTML string character by character. It identifies opening tags, closing tags, comments, doctypes and raw text blocks like <script> and <style>. When it encounters a block-level element such as <p>, <div> or <h1>, it inserts line breaks to separate the content. List items inside <ul> or <ol> are prefixed with a bullet or number.

Character references are decoded during tokenization. Numeric references like &#8364; are converted using String.fromCodePoint, while named references like &amp; are looked up against a built-in dictionary of over 250 standard HTML entities. Inline whitespace within a block is collapsed to single spaces, matching how browsers render text.

Supported HTML elements

The tokenizer handles all standard HTML constructs without relying on a browser DOM. Here is how different elements map to plain text:

Element typeExamplesPlain text behavior
Block elementsp, div, section, articleDouble newline between siblings
Headingsh1 through h6Double newline before and after
Line breaksbrSingle newline
Horizontal ruleshrNewline with dashes
Unordered listsul with liEach item prefixed with "- "
Ordered listsol with liEach item prefixed with "1. ", "2. ", etc.
Tablestable, tr, td, thCells separated by tabs, rows by newlines
LinksaText only, or text plus URL if enabled
Script and stylescript, styleCompletely removed
Comments<!-- ... -->Completely removed

If you need structured tabular output rather than plain text, consider using html table to csv or html table to json instead.

Entity decoding reference

HTML uses character entities to represent symbols that would otherwise conflict with markup syntax. This tool decodes them back to their Unicode characters. Below are some common examples:

EntityCharacterDescription
&amp;&Ampersand
&lt;<Less-than sign
&gt;>Greater-than sign
&quot;"Double quotation mark
&apos;'Apostrophe
&nbsp; Non-breaking space (converted to regular space)
&copy;©Copyright sign
&euro;€Euro sign

Numeric entities work too. Both decimal (&#8364;) and hexadecimal (&#x20AC;) forms resolve to the same Unicode code point.

Common mistakes when stripping HTML

Naive approaches to converting html to text often rely on simple regular expressions like replacing /<[^>]+>/g with an empty string. This fails in several real-world scenarios:

  • Script and style contents leak through. A regex strip leaves the JavaScript or CSS source visible in the output. This converter explicitly skips everything inside those tags.
  • Entities remain encoded. Users see &amp; instead of &. Proper decoding requires handling both named and numeric references.
  • Block structure is lost. Without recognizing block-level tags, paragraphs run together into a single unreadable wall of text.
  • List semantics disappear. Ordered and unordered lists lose their numbering and bullets, making instructions hard to follow.

For simpler cases where you just need to delete tags without formatting, the html tag remover may be sufficient. If you are working with XML rather than HTML, use xml to text instead.

Practical use cases

Converting html to text is useful whenever you need to move web content into a format that does not support markup. Common scenarios include:

  • Email processing. Many systems require a plain text alternative alongside HTML emails. Extracting readable text ensures accessibility for clients that cannot render markup.
  • Data extraction. When scraping or copying content from web pages, stripping tags leaves only the meaningful text for analysis or storage.
  • Content migration. Moving articles between CMS platforms sometimes requires an intermediate plain text step to avoid carrying over incompatible markup.
  • Word counting and readability analysis. Tools like the word counter work best on clean text without HTML noise.

If you need to preserve structural formatting like headings and emphasis, consider converting to Markdown using html to markdown instead of plain text.

Worked examples

ExampleInputResult
Simple paragraphHTML input: <p>Hello <strong>world</strong>!</p>; Show link URLs: noHello world!
List with linksHTML input: <ul><li><a href="https://example.com">Example</a></li><li>Item two</li></ul>; Show link URLs: yes- Example (https://example.com) / - Item two
Table and scriptHTML input: <script>alert('hi');</script><table><tr><td>A</td><td>B</td></tr></table>; Show link URLs: noA B

FAQ

Does this tool upload my HTML to a server?

No. The entire conversion happens locally in your browser using JavaScript. Your HTML input never leaves your device.

What happens to images and media tags?

Void elements like img, video and audio are ignored since they have no text content. If an image has an alt attribute, it is not extracted by default because alt text is metadata rather than visible page content.

Can I keep the URLs from links?

Yes. Check the Show link URLs option to append each anchor's href in parentheses after its display text (empty links, same-page # links and javascript: or data: links are skipped). For example, a link becomes: Example (https://example.com).

How are nested lists handled?

Nested lists are flattened. Each list item receives a bullet or number based on whether its immediate parent is ul or ol. Deep nesting does not add indentation in plain text mode.

Does it handle malformed HTML?

The tokenizer is lenient. Unclosed tags, missing quotes on attributes and stray angle brackets are handled gracefully without crashing. Content outside of recognized tags is treated as text.

What is the difference between this and an HTML minifier?

An HTML minifier like html minify removes whitespace but keeps the markup intact. This converter removes the markup entirely and returns only human-readable text.