Convert HTML to Plain Text: What Survives, What Gets Lost

A practical review of turning HTML into plain text: what the conversion changes, when it keeps meaning intact, and when you need structure, links or a better format.

Converting HTML to plain text strips away tags, attributes, scripts and styling and keeps the readable words. People search for this as "translating" HTML code to text, but no language translation happens. The goal is to get the human-readable content out of the markup. This review covers what the conversion changes, where it can quietly alter meaning, and how to tell whether the result will work for your purpose.

Is HTML-to-text conversion right for your use?

Plain text is usually the right choice when the destination cannot render HTML, or when only the words matter. Its main benefit is portability: plain text pastes cleanly into form fields, chat apps, plain-text email, spreadsheets, search indexes, word counters and diff tools, and it carries no hidden markup.

The tradeoff that decides most cases is lost structure. Headings, emphasis, link destinations, table layout and image descriptions are either flattened or dropped, depending on the converter. If a reader needs to follow links, compare table columns or tell a heading from body text, plain text can make the content harder to use or less accurate. A lightweight format such as Markdown keeps more of that structure.

  • Plain text is a good fit when:
  • The destination shows raw tags instead of rendering them.
  • You need the content for search, counting, comparison or indexing.
  • You want to remove formatting, tracking scripts or embedded styles before reusing text.
  • The content is mostly prose with few links or tables.
  • Plain text is a poor fit, or needs extra care, when:
  • Links, citations or references must keep their destinations.
  • Tables carry meaning through rows and columns.
  • Images matter and their descriptions must be kept.
  • Visual direction or styling changes how the text should be read.

What the conversion actually changes

An HTML document stores characters plus instructions about how to present them. Converting to plain text keeps the characters and discards the instructions, but converters differ on where they draw that line. Most of the important differences fall into the areas below.

Tags, entities and whitespace

Tags are removed, and character references are decoded into the characters they stand for. For example, & becomes & and < becomes <. A non-breaking space reference becomes the non-breaking space character, not an ordinary space. This can affect search, matching and line wrapping later on. HTML also collapses runs of spaces and line breaks when it displays a page, so a converter has to rebuild line breaks from block elements such as paragraphs, headings, list items and explicit line breaks. Preformatted sections are expected to keep their original spacing.

Here is an illustrative input and one reasonable plain-text result. This example was written for this article. It is not output captured from a specific tool.

<h2>Shipping &amp; Returns</h2>
<p>Orders ship in <strong>two</strong> business days.</p>
<ul>
  <li>Free returns</li>
  <li>Exchanges within 30 days</li>
</ul>
<script>trackVisit();</script>
Shipping & Returns

Orders ship in two business days.

- Free returns
- Exchanges within 30 days

The output matches the mechanism described above. The entity is decoded, the bold emphasis on "two" is gone, list items have been given a text marker by the converter, and the script contents are left out. A converter that only deletes anything between angle brackets would handle this differently. It would leave "trackVisit();" in the output and might run lines together. That is a common reason quick pattern-based stripping produces messy results.

Links, images and tables

A link's visible words usually survive, but its destination lives in an attribute and is often discarded. Some converters append the destination after the link text, others drop it. An image has no visible text of its own, so it disappears entirely unless the converter copies its alternative text. Tables are flattened into lines of cell text. Whether columns stay distinguishable depends on whether the converter inserts separators such as tabs.

Stored characters versus visual presentation

Some of what you see on a web page is presentation, not stored text, and a conversion can treat it either way. CSS can uppercase text, hide it, or insert generated content before or after an element. HTML can also change how text direction is displayed. The bidirectional override element, for example, can make characters stored as "abc" appear on screen as "cba". Plain-text extraction generally returns the characters in their stored, logical order without the direction instruction, so the copied text may not match what the page showed.

Browsers expose this difference through two documented DOM properties. textContent returns the stored text of an element, including text hidden by CSS. innerText is defined to take rendering into account, so it reflects visibility, line breaks and CSS text transforms. Tools built on either approach can produce noticeably different text from the same page. If hidden or visually altered content matters, check which behavior a tool uses.

Element | Typical plain-text result | What may be lost
Headings | Text on its own line | Heading level and hierarchy
Bold, italic | Plain words | Emphasis that carried meaning
Links | Link text only, sometimes with destination appended | Where the link pointed
Images | Nothing, or alternative text if the tool keeps it | The image's description
Lists | Lines, sometimes with markers or numbers | Nesting and numbering, if not rebuilt
Tables | Cell text on lines, sometimes tab-separated | Row and column relationships
Scripts and styles | Removed by structure-aware tools | Nothing readable, if handled correctly
CSS-hidden text | Kept or removed, depending on the extraction method | Consistency with what was displayed
Direction overrides | Stored logical order | The displayed visual order

Extracting text from a web address instead of pasted code

Some tools take a page address and fetch the HTML themselves. The result depends on what they fetch. Raw page source may not contain text that the page loads later with JavaScript, so content visible in a browser can be missing from the extracted text. Fetched pages also include navigation menus, footers and cookie notices. A tool may keep these or try to isolate the main article, and those heuristics can cut real content. When completeness matters, compare the extracted text against the page as displayed.

Will the result stay readable after copying or sharing?

Plain text is among the most portable formats for copying and pasting, because it has no markup to misinterpret. A few problems still come up. Non-breaking spaces and other invisible characters carried over from the HTML can cause odd wrapping or failed searches. Line breaks may be rewrapped by the destination. Plain text pasted back into a web page must be escaped, or characters such as < and & will be read as markup again.

Accessibility cuts both ways. Removing raw tags makes content more readable in places that would otherwise show markup. However, assistive technology relies on HTML structure, such as heading levels, list semantics, table headers and image alternative text, to help people navigate. Once that structure is flattened, a screen reader user loses those navigation aids. If the text is going somewhere it will be read with assistive technology, keep headings and alternative text in some form, or publish the original structured version alongside it. No destination-specific or screen-reader testing was available for this review, so how a particular app or reader handles converted text should be checked directly.

Searching and editing are generally easier on plain text, since what you search is exactly what is stored. Meaning that depended only on formatting, such as an emphasized warning, a struck-through price or a table column header, has to be restated in words if it matters.

How to judge a converter

  • Run a sample that includes an entity, a non-breaking space, a link, an image with alternative text, a table and a script block, then inspect what comes out.
  • Check whether line breaks follow paragraphs and list items, or whether text runs together.
  • Find out whether link destinations and image alternative text are kept, dropped or optional.
  • For pages fetched by address, compare the output with the rendered page to catch missing dynamic content or over-trimmed sections.
  • Do not assume how a tool handles privacy or data retention from its design or marketing. If the HTML contains sensitive material, check the provider's stated policy or use a local method.

Evidence gaps

No specific tools, test results or measurements were provided for this review, so no product is rated or recommended. The behaviors described here are general properties of HTML and of documented browser text extraction. The examples are illustrations, not captured output. How any particular converter, destination app or assistive technology behaves should be confirmed with a scoped test on your own content.