Convert HTML to Plain Text
What HTML-to-text conversion keeps and drops, how its methods differ, and when plain text stays readable and accessible after you copy or share it.
Converting HTML to plain text removes the markup and keeps the readable words. The result opens in any editor, pastes without stray styling, and works where tags would otherwise show up as clutter. The cost is that anything the markup expressed is gone: structure, emphasis, link destinations and table relationships. This review explains what the conversion changes, how the common methods differ, and how to judge whether the output still works for your purpose.
Is plain text the right output for your use?
Convert when the destination only accepts or displays plain text, or when you need the words without markup for processing. Typical cases are the text part of an email, SMS and notification messages, form fields and content fields that strip formatting, search indexing, word counts, text analysis, and archives that should stay readable in any editor. The main benefit is portability: the output contains no hidden code and behaves predictably almost anywhere. The decisive tradeoff is that meaning carried by markup disappears unless the converter writes it into the text. That includes heading levels, emphasis, link addresses, table headers and image descriptions.
Plain text is preferable when readers only need the words in order and the destination would otherwise show raw tags or mangle formatting. Keep the HTML, or use a lightweight structured format such as Markdown, when structure is part of the meaning. That applies to data tables, numbered instructions, code samples and link-heavy documents.
What the conversion actually changes
An HTML document is text mixed with instructions about structure and appearance. Conversion keeps the text and discards the instructions. Most converters do some combination of the following:
- Tags removed: elements such as <p>, <strong> and <div> disappear, and the text inside them stays.
- Character references decoded: & becomes &, < becomes <, and numeric references such as é become é.
- Non-content elements dropped: well-built converters discard the contents of script and style elements. Naive tag stripping can leave JavaScript or CSS text in the output.
- Whitespace normalized: source indentation and line breaks are collapsed, and block elements such as paragraphs, headings, list items and table rows are turned into line breaks.
- Optional rewriting: some tools add bullet characters, mark headings, append link addresses in brackets or insert image alt text. Others do none of this, so check a sample before relying on any of these behaviors.
Stored characters versus visual presentation
Many differences between a web page and its plain-text version come from CSS, which changes appearance without changing the stored characters. A heading displayed in capitals with text-transform: uppercase is still stored in mixed case, so a converter that reads the source returns the original case. Fonts, colors and sizes vanish entirely, because plain text has no font. Text generated by CSS, such as ::before and ::after content, is not in the document text and is usually lost. The same applies to the numbers a browser draws for ordered lists, so a numbered procedure can lose its step numbers. Elements hidden with display: none still exist in the source. A converter that ignores CSS may include them, while copying from a rendered page normally leaves them out.
The terms "reverse", "mirror" and "font" do not apply to this transformation. HTML-to-text conversion does not reverse character order, mirror glyphs or swap letters for styled Unicode look-alikes. If a page already contains look-alike characters, such as mathematical bold letters, conversion passes them through unchanged, along with their search and screen-reader problems. Bidirectional text needs a closer look. Arabic and Hebrew are stored in logical order, and that order survives conversion. Direction set by dir attributes or bdi elements is markup, however, and is dropped. Mixed right-to-left and left-to-right passages may then display in a different order, because the destination applies only the Unicode bidirectional algorithm. Check such content in the target application.
A worked example
Input fragment:
<h1>Spring Sale</h1>
<p>Save on <strong>all</strong> items & get free shipping.</p>
<ul>
<li>Shoes</li>
<li>Bags</li>
</ul>
<script>trackVisit();</script>
One plausible output from a converter that drops scripts, decodes entities and marks list items:
Spring Sale
Save on all items & get free shipping.
- Shoes
- Bags
Each part of this output follows from the steps above. The tags are gone, and & is decoded to &. The emphasis on "all" is removed without a trace. The script contents are dropped, and each list item is on its own line, with the hyphens added by this converter rather than taken from the source. A naive regular expression that only deletes tags behaves differently. It keeps whatever line breaks and indentation the source happened to contain, leaves & undecoded and leaks "trackVisit();" into the text. The example contains no combining marks or emoji. Conversion does not reorder characters, so such sequences pass through intact as long as the text encoding is read and written correctly.
Ways to convert, and how they differ
- Copy from the rendered page: select the content in a browser and paste it into a plain-text editor or use paste-as-plain-text. You get roughly what is visible, with hidden elements left out and CSS case changes applied. Results depend on the browser and the destination.
- Online converters: paste HTML or upload a file and receive text. This is convenient, but the output rules vary between tools. No evidence about any service's data handling was available for this review, so do not assume uploads are private or deleted. Avoid pasting confidential markup unless the service documents its retention practices.
- Scripts and libraries: these are repeatable, run locally and are configurable. In the browser DOM, textContent returns all text nodes, including script and style contents, without line breaks for block elements. innerText is rendering-aware, but on a document that is not rendered it behaves like textContent.
- Regex tag stripping: quick but fragile. It misses entity decoding, comments and script contents, and it can break on attribute values that contain the > character.
A minimal browser-side approach that parses the HTML without executing its scripts:
const doc = new DOMParser().parseFromString(html, "text/html");
doc.querySelectorAll("script, style, noscript").forEach(el => el.remove());
const text = doc.body.textContent.replace(/\s+/g, " ").trim();
This snippet decodes entities and removes script and style content. It also collapses all whitespace, so paragraph breaks are lost. If line breaks matter, insert newlines after block-level elements before extracting the text, or use a library built for HTML-to-text conversion. Treat the snippet as a starting point, not a complete converter.
Converting HTML files and saving as .txt
Files follow the same rules, with a few additional checks. Make sure the source encoding, declared in a meta charset tag or a server header, is read correctly. A mismatch turns accented letters and symbols into garbled characters. Save the output as UTF-8 to keep non-ASCII characters and emoji. Windows uses CRLF line endings and Unix-like systems use LF; most current editors handle both, but some older tools do not. A full page also includes navigation, footers and notices, and a converter cannot tell these from the main content. Extract the relevant region, such as the main or article element, first, or expect to clean up the output by hand.
Will the result stay readable and usable after copying or sharing?
For copy and paste, plain text is the most predictable form, because no styling travels with it. Some invisible characters do carry over, though. A decoded becomes a non-breaking space (U+00A0), which looks like an ordinary space but can defeat searching, find-and-replace and data parsing. Zero-width characters and soft hyphens from cause similar problems. Normalize these characters if the text feeds into another system.
Plain text follows source order. CSS layouts that use flexbox ordering, grid placement or absolute positioning can display content in a different visual sequence, and the converted text will then read in an unexpected order. Screen readers generally follow source order too, so pages built with accessible source order usually convert more coherently.
In HTML, screen reader users can jump between headings, hear lists announced with item counts, have table cells related to their headers, and hear image alt text. Plain text removes these navigation aids, so a long converted document becomes a continuous stream that is harder to move through. Images without alt text disappear completely, and alt text survives only if the converter inserts it. When the plain-text version is the only one readers get, as with an email's text part, edit it deliberately. Keep link destinations visible, separate sections with blank lines and number steps explicitly. No assistive technology or destination application was tested for this review, so confirm behavior with the specific reader and app you care about.
Tables suffer most. Flattened rows become lines of values separated by spaces or tabs, and the link between each value and its column header is lost. Wide tables quickly become unreadable. Rewrite important tables as sentences, or keep them in a structured format.
Plain text indexes, searches and edits easily, but signals such as headings, emphasis and link relationships are gone. If converted text is later inserted back into a web page, escape characters like < and & again. Otherwise, text that looks like markup may be interpreted as markup, which is an injection risk when the original HTML came from an untrusted source.
| HTML element | Typical plain-text result | What to check |
| Headings | Own line, level lost | Whether sections need blank lines or markers |
| strong / em | Words kept, emphasis gone | Whether emphasis carried meaning, such as a warning |
| Links | Anchor text kept, address usually dropped | Whether readers need the destination |
| Images | Removed, or replaced with alt text | Information lost when alt text is missing |
| Ordered lists | Items on separate lines, numbers depend on the tool | Whether step numbers survive |
| Tables | Cells flattened into lines | Header relationships and readability |
| script / style | Should be removed | Leaked code in the output |
| Entities such as | Decoded to characters | Invisible special spaces |
| dir attributes / bdi | Removed | Display order of mixed-direction text |
When you need a separate plain-text version
Automatic conversion is usually enough for processing tasks such as indexing, counting and analysis, where no one reads the structure. When people will read the result in a plain-text-only destination, such as an email text alternative, an SMS, a notification or an accessibility fallback, review and edit the output. Restore link destinations, number steps explicitly, describe images that carry information and rewrite tables as prose.
Evidence gaps
No specific converter was tested for this review, and no measurements, prices or comparisons were supplied. Descriptions of tool behavior reflect common approaches and documented web-platform behavior, not verified results for any named product. The privacy and data retention practices of online converters are unknown here, so check each tool's own documentation. Always verify the output in the destination where it will actually be used.