Skip to content

HTML Cleaner

Paste HTML or formatted text, choose what to remove and get clean markup in one click.

Visual editor
Loading visual editor…
Cleaning options (6 selected)

All tags keeps only text. Need plain text? Use HTML to Text.

More options
Find and replace in HTML source
Ctrl+Enter
Runs in your browser — your data is not uploaded. Images in the visual editor are loaded from their original URLs.

How to use

  1. Paste your HTML into Code, or use Upload to open a file.
  2. Choose a Preset, or check the individual cleaning options you need.
  3. Click Clean HTML to replace the editor content with the cleaned markup.
  4. Click Copy HTML to copy the result, or Download to save an HTML file.

Examples

Clean a quarterly report from Word

Input
<p class=MsoNormal><b style="mso-bidi-font-weight:normal"><span style="font-size:12pt;mso-ansi-language:EN-US">Quarterly report</span></b><o:p></o:p></p>
<p class=MsoNormal style="margin-bottom:0cm;line-height:normal"><span lang=EN-US style="font-family:Calibri">Prepared for&nbsp;<i>internal</i> use.<o:p></o:p></span></p>
<!--[if gte mso 9]><xml><o:OfficeDocumentSettings></o:OfficeDocumentSettings></xml><![endif]-->
Output
<p><strong>Quarterly report</strong></p>
<p>Prepared for <em>internal</em> use.</p>

Remove extra CMS markup

Input
<div class="entry-content" data-id="42" style="padding:0">

  <p class="lead" style="color:#333">Free shipping on orders over&nbsp;$50.</p>
  <p><span class="spacer"> </span></p>
  <p><a href="/shipping" class="btn" target="_blank">Shipping details</a></p>

</div>
Output
<div>
  <p>Free shipping on orders over $50.</p>
  <p><a href="/shipping">Shipping details</a></p>
</div>

Extract body content without scripts

Input
<!doctype html>
<html><head><title>Store hours</title></head><body>
<h2>Chicago store</h2>
<p onclick="trackVisit()">Open Monday through Friday, 9 a.m. to 6 p.m.</p>
<script>function trackVisit() { console.log('visit'); }</script>
<a href="javascript:window.print()">Print hours</a>
</body></html>
Output
<h2>Chicago store</h2>
<p>Open Monday through Friday, 9 a.m. to 6 p.m.</p>
<a>Print hours</a>

Cleaning options explained

1. Styles

Removes inline style attributes and <style> blocks, so the page CSS decides how text looks.

Before
<style>p { color: blue }</style>
<p style="color:red">Lorem ipsum <span style="color:green">dolor</span> sit amet.</p>
After
<p>Lorem ipsum <span>dolor</span> sit amet.</p>

2. Empty attributes

Removes attributes with an empty or blank value, like class="" or id=" ". Boolean attributes and alt="" stay.

Before
<p class="" id=" ">Lorem ipsum</p>
<img src="logo.png" alt="">
After
<p>Lorem ipsum</p>
<img src="logo.png" alt="">

3. Links

Unwraps links: the <a> tag goes, its text and inner elements stay.

Before
<p>Read <a href="https://example.com" target="_blank">our guide</a> first.</p>
After
<p>Read our guide first.</p>

4. Tags with whitespace

Removes elements that contain only spaces or &nbsp;, such as the empty paragraphs Word leaves behind.

Before
<p>First</p>
<p>&nbsp;</p>
<p> </p>
<p>Second</p>
After
<p>First</p>


<p>Second</p>

5. Classes and IDs

Removes class and id attributes from every element.

Before
<p id="intro" class="lead text-muted">Lorem ipsum <span class="hl">dolor</span>.</p>
After
<p>Lorem ipsum <span>dolor</span>.</p>

6. Empty new lines

Deletes blank lines and lines with only spaces. Code inside <pre> and <textarea> is left alone.

Before
<ul>

  <li>One</li>


  <li>Two</li>

</ul>
After
<ul>
  <li>One</li>
  <li>Two</li>
</ul>

7. Tables

Deletes tables together with everything inside them.

Before
<p>Before</p>
<table><tr><td>1</td><td>2</td></tr></table>
<p>After</p>
After
<p>Before</p>

<p>After</p>

8. All tags attributes (except href and src)

Strips every attribute except href and src. Note that alt, colspan and rowspan go too.

Before
<a href="/x" class="c" target="_blank"><img src="i.png" alt="Logo" width="10"></a>
After
<a href="/x"><img src="i.png"></a>

9. Span tags

Unwraps <span> elements and keeps their text.

Before
<p><span style="font-family:Arial">Lorem</span> <span class="x">ipsum</span></p>
After
<p>Lorem ipsum</p>

10. Empty tags

Removes elements with no content at all. Images, line breaks, table cells and anchors like <a name="top"></a> are kept.

Before
<p>Text<b></b></p>
<div><span></span></div>
<a name="top"></a>
After
<p>Text</p>

<a name="top"></a>

11. Forms

Deletes <form> elements with their content, plus stray inputs, selects, textareas and buttons.

Before
<p>Subscribe:</p>
<form action="/s"><input name="email"><button>Go</button></form>
After
<p>Subscribe:</p>

12. JS code scripts

Removes <script> blocks, on* event attributes and javascript: links.

Before
<p onclick="track()">Hi</p>
<script>alert(1)</script>
<a href="javascript:void(0)">Menu</a>
After
<p>Hi</p>

<a>Menu</a>

13. Comments

Removes HTML comments, including Word conditional comments like <!--[if mso]>.

Before
<!-- header -->
<p>Lorem ipsum</p>
<!--[if mso]><p>Outlook only</p><![endif]-->
After
<p>Lorem ipsum</p>

14. Non-breaking spaces

Replaces &nbsp; with a normal space, so words never get glued together.

Before
<p>Lorem&nbsp;ipsum&nbsp;dolor</p>
After
<p>Lorem ipsum dolor</p>

15. Images

Deletes <img> and <picture> elements.

Before
<p>Logo: <img src="logo.png" alt="Logo"> Company</p>
After
<p>Logo:  Company</p>

16. All tags

Removes every tag and keeps only the text, one line per block. Scripts, styles and the head are dropped.

Before
<h1>Title</h1>
<p>Fish &amp; chips<br>Daily</p>
<script>x()</script>
After
Title

Fish &amp; chips
Daily

Find and replace in HTML source

Open Find and replace in HTML source under the options to add up to 10 rules. Each rule replaces every match in the code — as plain text, or as a regular expression with $1…$9 and $& in the replacement. Rules run after cleaning when Apply on Clean is on, or right away with Replace now; both can be undone.

FAQ

Will cleaning HTML remove my tables or image alt text?

Tables are removed only if you check Tables, which deletes tables and everything inside them. All tags attributes (except href and src) is checked by default and removes colspan, rowspan and image alt text; uncheck it to keep those attributes.

What file types and sizes can I upload?

Upload accepts .html, .htm, .xhtml and .txt files up to 10 MB. If cleaning takes too long, try fewer options or split the document into smaller parts.

Is my HTML sent to a server?

Cleaning runs in your browser, and the tool does not upload or save your HTML. The visual editor can load images and other displayed resources from their original URLs, so those servers can see your IP address.

Why does &copy; change to © after cleaning?

The cleaner parses HTML into a DOM and writes it back, converting named entities such as &copy; to characters. It also adds double quotes around attribute values and closes unclosed tags.

Can I remove HTML tags to get plain text?

All tags removes markup, but the result remains HTML-escaped, so an ampersand appears as &amp;. Use HTML to Text if you need plain text without HTML escaping.