HTML to Text Converter

Strip HTML tags from any markup, or wrap plain text in basic HTML.

Converting between HTML and plain text

This tool works in both directions. Strip HTML to pull clean readable text out of markup, or wrap plain text in basic HTML paragraphs to get valid markup from a draft.

Key takeaways

  • Stripping tags leaves the text content and decodes HTML entities.
  • Block-level elements become line breaks; inline elements do not.
  • Script and style contents are removed entirely, not converted to text.
  • Wrapping text in HTML escapes the reserved characters so they display correctly.
  • Stripping tags is not the same as sanitizing untrusted input.

HTML to text

Stripping HTML involves more than deleting anything between angle brackets:

  1. Remove script and style blocks entirely, including their contents, which are code rather than readable text.
  2. Convert block-level elements to line breaks so paragraph structure survives.
  3. Remove all remaining tags, keeping the text between them.
  4. Decode HTML entities - & becomes &,   becomes a space.
  5. Collapse excess whitespace, since HTML source is usually indented.
HTML inputPlain text output
<p>Hello <strong>world</strong></p>Hello world
<h1>Title</h1><p>Body</p>Title ⏎ Body
<a href="#">Click</a>Click
Fish &amp; chipsFish & chips
<script>alert(1)</script>TextText
<br>A line break
Links lose their destination. Stripping tags keeps the anchor text but discards the href entirely, so "<a href="https://example.com">click here</a>" becomes just "click here". If you need the URLs, run the HTML through the URL extractor first.

Text to HTML

Going the other way wraps text in basic markup and escapes anything that would otherwise be interpreted as HTML:

CharacterEscaped asWhy
<&lt;Would otherwise start a tag
>&gt;Would otherwise close a tag
&&amp;Starts an entity reference
"&quot;Can break out of an attribute
'&#39;Can break out of an attribute

Blank lines become paragraph breaks and single line breaks become
tags, which mirrors how most people expect plain text to translate.

Block versus inline elements

Whether an element becomes a line break depends on how it displays:

  • Block elements - p, div, h1 to h6, li, tr, blockquote, section - start on a new line, so they become line breaks.
  • Inline elements - span, a, strong, em, code, small - flow within a line, so they leave no trace at all.
  • Void elements - br produces a break, hr often becomes a separator, img may leave its alt text or nothing.

Where this is useful

  • Getting clean text out of a web page without the formatting noise.
  • Preparing a plain-text version of an HTML email, which improves deliverability.
  • Extracting content for word counting or readability analysis.
  • Cleaning content pasted from a word processor, which carries enormous amounts of junk markup.
  • Converting a draft into valid HTML to paste into a CMS.
  • Producing accessible text alternatives from rich content.

Stripping tags is not sanitizing

Do not rely on tag stripping as an XSS defense. Removing tags from untrusted input is not the same as sanitizing it. Attackers have many ways to smuggle executable content past naive strippers - malformed tags, unusual encodings, event handlers in surviving attributes. For user-generated content, use an established sanitizing library with an allow-list of permitted elements and attributes, and escape on output.

This tool is a convenience for content you control, not a security boundary.

Everything happens in your browser. Your text is processed entirely on your own device using JavaScript. Nothing is uploaded, stored or logged, which means you can safely paste confidential drafts, client work or personal notes. Closing the tab discards everything.

Frequently Asked Questions

How do I strip HTML tags from text?

Paste the HTML into the tool and choose the HTML to text direction. It removes script and style blocks entirely, converts block-level elements to line breaks, strips remaining tags, decodes HTML entities and collapses excess whitespace.

Does stripping tags keep the link URLs?

No. Only the anchor text survives, so a link becomes just the words that were clickable. If you need the destinations too, run the HTML through a URL extractor before stripping the tags.

What happens to HTML entities?

They are decoded back to the characters they represent - &amp; becomes an ampersand, &nbsp; becomes a space, &lt; becomes a less-than sign. Leaving them encoded would produce text full of visible entity codes.

Why do some tags create line breaks and others do not?

Because block-level elements such as p, div and h1 start on a new line in rendered HTML, so a line break preserves that structure. Inline elements such as span, strong and a flow within a line, so removing them leaves no gap.

Is stripping HTML tags enough to make user input safe?

No. Tag stripping is not sanitization. Attackers can smuggle executable content past naive strippers using malformed tags, unusual encodings or surviving event handlers. Use an established sanitizing library with an allow-list, and escape on output.

How do I convert plain text into HTML?

Choose the text to HTML direction. Blank lines become paragraph tags, single line breaks become br tags, and reserved characters such as angle brackets and ampersands are escaped so they display as intended rather than being parsed as markup.

Can I use this to clean text pasted from Word?

Yes, and it is one of the better uses for it. Word carries a very large amount of proprietary markup into any paste. Converting to plain text and then back to HTML strips all of it and leaves clean, minimal markup.

Is my content uploaded anywhere?

No. Conversion runs entirely in your browser and nothing is transmitted or stored. Closing the tab discards it.

Related Calculators