Home/Text tools/HTML to text

Text tool

HTML to Text

Paste HTML, get plain text with paragraphs and list structure kept as real line breaks — parsed with the browser's own DOMParser instead of a regex that strips angle brackets.

Block versus inline elements — where line breaks come from

Plain text has no tags of its own, so the converter has to decide when an element's boundary should become a line break. The rule follows how browsers render each element visually: block-level elements start a new visual line, inline elements do not.

Which HTML elements force a line break in the plain-text output
ElementTypeEffect on plain text
<p>BlockBlank line before and after
<h1><h6>BlockBlank line before and after
<div>BlockLine break before and after
<li>Block (inside a list)One per line, with a leading - for unordered lists or a number for ordered lists
<br>Line break elementA single line break, no blank line
<table>, <tr>BlockEach row on its own line, cells separated by a tab
<strong>, <em>, <span>, <a>InlineNo line break — text flows straight through, styling is simply dropped
<script>, <style>Non-visible contentEntire contents removed, not converted to text

Why regex tag-stripping is unsafe

A pattern like text.replace(/<[^>]+>/g, "") looks like it should work, and mostly does, until it meets real-world HTML. Three ways it breaks:

This tool instead hands the input to the browser's own DOMParser, the same parser that renders every web page you visit. It builds a real DOM tree, which means script and style content is properly excluded, malformed markup is corrected the same way a browser corrects it for display, and the walk through block versus inline elements is done on actual parsed nodes rather than string patterns.

Questions people ask

Are HTML entities like &amp; and &mdash; decoded?

Yes. Since the browser's own parser builds the DOM, entities are decoded the same way they would be for on-page rendering — &amp; becomes &, &mdash; becomes an em dash, and numeric entities like &#39; decode to their character too.

Does this run any embedded JavaScript from the pasted HTML?

No. DOMParser parses markup into a document without executing scripts, images do not load, and no network requests fire — it is inert by design, which is also why it is safe to paste HTML from an untrusted source here.

What happens to images?

<img> has no text content of its own, so it produces nothing in the output. If you need the alt text preserved, that would need to be added as a separate rule — currently it is dropped along with the tag.

Does list nesting work correctly?

Nested <ul> or <ol> elements are indented one level per level of nesting, so a sub-list reads as visually nested nested in the plain-text output rather than flattened to the same indentation as its parent list.

Cleaning up markup for somewhere else?

Markdown preview, whitespace cleanup and word counting sit right next door.

See all text tools →