Text FIELD NOTES · 4 MIN READ
Stripping HTML: How Markup Becomes Plain Text
Five passes — script and style removal, block tags as breaks, tag stripping, entity decoding, whitespace tidying — turn markup into text.
Copy anything from a web page and invisible luggage comes along: tags, scripts, entity codes, whitespace arranged for a browser rather than for you. The HTML to Text Converter unpacks it all in five passes, and each pass has a rule worth knowing before you trust the output.
The pipeline, step by step
Conversion runs in a fixed order. First, <script> and <style> blocks are removed whole — code and CSS are not visible text, so their content vanishes along with their tags. Second, closing block-level tags and <br> become line breaks. Third, every remaining tag is stripped. Fourth, entities are decoded. Fifth, whitespace is tidied: each line is collapsed and trimmed, runs of blank lines shrink to a single blank line, and the ends are trimmed. Each pass is a plain string operation — effectively one search-and-replace per job — which is why the conversion is instant even on large documents and why the passes behave the same on a two-line snippet and a full saved page. Watch the whole pipeline on a small page:
<h1>Weekly plan</h1>
<p>Buy <b>apples</b> and <b>pears</b>.</p>
<script>track()</script>
<ul><li>Call the bank</li><li>Water the plants</li></ul>
<!-- note -->
becomes:
Weekly plan
Buy apples and pears.
Call the bank
Water the plants
Comments disappear in the stripping pass too — anything angle-bracketed has no visible text to lose.
Where line breaks come from
Line breaks are manufactured, not inherited: the converter decides where they go by tag type. Closing tags of paragraphs, divs, headings (h1–h6), list items, table rows, and section-level containers — section, article, header, footer, nav, blockquote — each become one line break, and <br> becomes one as well. Inline tags — <b>, <i>, <a>, <span>, <em> — never break a line, which is why Buy apples and pears. survives its bold tags as one sentence. After the break pass, three or more consecutive newlines collapse to a single blank line, so spacing chaos in the source produces calm, repeatable output.
What disappears, what survives
Everything only a browser could love is removed: script and style bodies, comments, attributes, and the tags themselves. What survives is exactly what a reader would see — visible text, in reading order, with block boundaries as line breaks. The result is inert: no tag survives, so the output cannot carry markup or scripts anywhere it is pasted. That makes it safe for plain-text contexts — emails, notes, ticket systems — and clean enough to feed to tools that expect plain input, such as the Word Counter or Text Statistics.
Typical jobs fit that description. A styled HTML email becomes a plain-text version before archiving or replying. An article can be pulled out of a saved page without the surrounding chrome. And any tool that wants words rather than markup — keyword extractors, diff tools, counters — gets cleaner input after a strip. Because every pass is text surgery on the string itself, the whole conversion runs in your browser: nothing is uploaded, and pasted snippets stay on your machine.
Entities: what decodes and what does not
Entities are HTML's escape sequences, and the converter decodes the common practical cases: becomes a plain space, and ' becomes an apostrophe. A few named entities — &, <, > — are left as written, so text containing them passes through unchanged. If your source leans heavily on entities, expect mostly-clean output with those stragglers intact. How HTML Entities Work explains the whole escape system and why it exists.
Try it yourself
Paste the snippet above — or the source of any small web page — into the HTML to Text Converter and trace each pass: script gone, breaks in place, tags gone, whitespace calm. If the output lines have ragged ends, finish with the Trim Whitespace tool. And for the opposite direction — building markup up from plain text — the Markdown to HTML tool is the mirror image: one strips tags down, the other adds them back.