Skip to content
T
Tools.Town
Free Online Tools for Everyone
Text Tools

Stripping HTML to Plain Text: Tags, Entities, and Whitespace

A practical guide to removing HTML from text — how stripping handles tags, script and style blocks, entities, and whitespace, and when to strip versus convert.

24 June 2026 4 min read By Tools.Town Team Fact Checked

Key Takeaways

  • When tags are replaced by spaces, the whitespace that surrounded them adds up, leaving multiple spaces or blank lines
  • If you want human-readable output, yes — otherwise & and ' survive the strip and show up literally in your plain text
  • Stripping discards all formatting and leaves only words

The problem with copied content

You copy a paragraph from a web page, an email, or a content management system, and what lands in your clipboard is not the clean text you saw — it is a tangle of <span> wrappers, &nbsp; entities, and stray attributes. Paste that into a spreadsheet cell or a plain-text field and the markup comes along for the ride. Stripping HTML solves this by removing every tag and leaving only the readable content. The HTML Stripper does it in one pass, with controls for the three things that usually go wrong: leftover code, undecoded entities, and messy whitespace.

Tags are the easy part — script and style are the trap

Removing visible tags like <p>, <strong>, and <a> is straightforward: find anything between angle brackets and delete it. The trap is <script> and <style>. Their contents are code, not text, so if you only remove the tags you are left with raw JavaScript and CSS dumped into your output. A correct stripper deletes those elements whole — opening tag, content, and closing tag — before it touches anything else. The HTML Stripper handles this automatically, so a page full of inline scripts still gives you clean prose.

Comments are a similar case. An HTML comment is invisible in the browser but its text is still in the source, so stripping should remove comment blocks entirely rather than leaving their contents behind.

Entities: the second pass

Once the tags are gone, you are often left with HTML entities&amp;, &lt;, &#39;, &nbsp;. These are encoded stand-ins for characters that have special meaning in markup. For plain-text output you almost always want them decoded back to the real characters: &amp; to &, &#39; to an apostrophe, &nbsp; to a space. Decoding is a separate step from stripping, which is why the tool exposes it as a toggle. If your stripped text is destined for another HTML context, you might keep the entities encoded; for everything else, decode them. (If you only need to encode or decode entities without stripping anything, the dedicated entity tool is the better fit.)

Whitespace: the part everyone forgets

Here is the subtle one. When you replace a tag with a space, the whitespace that already surrounded the tag does not disappear — it accumulates. A list where every </li> becomes a space, sitting next to the newlines in the source, produces output riddled with double spaces and blank lines. Collapsing whitespace fixes this by squeezing every run of spaces, tabs, and newlines down to a single separator and trimming the ends. This is why the HTML Stripper turns whitespace collapse on by default; the same principle powers the dedicated Remove Extra Spaces tool for text that is already plain.

There is a tension, though: collapsing everything also flattens your paragraphs into one long line. If you want to keep a sense of the document’s shape, the “preserve line breaks” option converts block-level boundaries — closing paragraphs, list items, headings, <br> — into newlines before collapsing the rest. You lose the tags but keep the rough layout, which reads far better for long content.

Strip, format, or convert: choosing the right tool

Three operations sound similar but solve different problems, and picking the right one saves frustration:

  • Strip when you want only the words and none of the formatting. That is the HTML Stripper.
  • Format when you want to keep the HTML but make it readable — re-indenting minified markup. That is the HTML Formatter.
  • Convert when you want to keep the structure in a portable, lightweight syntax. That is HTML to Markdown.

Asking “do I want the words, the readable markup, or the structure preserved?” points you straight at the right tool.

A practical workflow

When you paste rich content and need plain text, a reliable sequence is: strip the tags, decode the entities, and collapse the whitespace — then decide whether you want line breaks back for readability. The HTML Stripper bundles all four into one screen, and because the transform is deterministic, you can trust that the same messy input always cleans up the same way. For text that is already tag-free but still untidy, follow up with the Remove Extra Spaces approach to finish the job.

Edge cases that bite

Stripping HTML looks trivial until you meet the inputs that break naive approaches, and it is worth knowing them so you trust your output. The first is angle brackets that are not tags. Text like 5 < 10 and 20 > 15 contains literal less-than and greater-than signs that a crude “delete everything between angle brackets” rule will happily eat, taking your real content with it. Robust stripping only removes sequences that actually look like tags, and decoding entities afterwards restores any &lt; and &gt; that were legitimately encoded.

The second is malformed or unclosed markup. Real-world HTML from emails and content systems is frequently broken — an <a with no closing bracket, a <div> that never closes, mismatched nesting. A stripper has to be tolerant: it should remove what it can recognise as a tag and leave the rest as text rather than crashing or silently dropping content. Deterministic, forgiving behaviour is what makes the result trustworthy on messy input.

The third is the whitespace-vs-readability trade-off. Collapsing all whitespace gives the tidiest single block of text, but flattens paragraphs into one run-on line. Preserving line breaks keeps structure but can leave more blank space than you want. There is no universally right answer; it depends on whether the destination is a search index (collapse everything) or a human reader (keep the breaks). The HTML Stripper exposes both as toggles precisely because the correct choice is contextual.

Finally, remember that stripping is lossy and one-way. Once the tags are gone, the structure is gone — you cannot reconstruct the original HTML from the plain text. If there is any chance you will need the formatting back, keep the original, or convert to Markdown instead so the structure survives in a portable form.

Key takeaways

Stripping is more than deleting tags: handle script and style blocks by removing their contents entirely, decode entities when you want readable output, and always think about whitespace, which silently accumulates when tags become spaces. Preserve line breaks when layout matters. And remember the broader map — strip for words, format for readable markup, convert for portable structure — so you reach for the right tool the first time.

Advertisement

Try HTML Stripper — Free

Apply what you just learned with our free tool. No sign-up required.

Try HTML Stripper

Frequently Asked Questions

Why does stripped text sometimes have weird gaps?
When tags are replaced by spaces, the whitespace that surrounded them adds up, leaving multiple spaces or blank lines. Collapsing whitespace fixes this by squeezing runs of spaces and newlines down to single separators, which is why the option is on by default.
Do I need to decode entities after stripping?
If you want human-readable output, yes — otherwise &amp; and &#39; survive the strip and show up literally in your plain text. Decode entities when the destination is a document or message; leave them encoded if the text is heading back into another HTML context.
What is the difference between stripping and converting to Markdown?
Stripping discards all formatting and leaves only words. Converting to Markdown preserves structure — headings, links, lists, emphasis — in a lightweight text syntax. Choose stripping when you want plain text, and conversion when you want to keep the formatting in a portable form.

Was this guide helpful?

Your feedback helps us improve our content.

Continue Reading

All Text Tools Guides

Get the best Text Tools tips & guides in your inbox

Join 25,000+ users who get our weekly text tools insights.