How to use
- Paste your HTML into Code, or use Upload to open a file.
- Choose a Preset, or check the individual cleaning options you need.
- Click Clean HTML to replace the editor content with the cleaned markup.
- Click Copy HTML to copy the result, or Download to save an HTML file.
Examples
Clean a quarterly report from Word
<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 <i>internal</i> use.<o:p></o:p></span></p> <!--[if gte mso 9]><xml><o:OfficeDocumentSettings></o:OfficeDocumentSettings></xml><![endif]-->
<p><strong>Quarterly report</strong></p> <p>Prepared for <em>internal</em> use.</p>
Remove extra CMS markup
<div class="entry-content" data-id="42" style="padding:0"> <p class="lead" style="color:#333">Free shipping on orders over $50.</p> <p><span class="spacer"> </span></p> <p><a href="/shipping" class="btn" target="_blank">Shipping details</a></p> </div>
<div> <p>Free shipping on orders over $50.</p> <p><a href="/shipping">Shipping details</a></p> </div>
Extract body content without scripts
<!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><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.
<style>p { color: blue }</style>
<p style="color:red">Lorem ipsum <span style="color:green">dolor</span> sit amet.</p><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.
<p class="" id=" ">Lorem ipsum</p> <img src="logo.png" alt="">
<p>Lorem ipsum</p> <img src="logo.png" alt="">
3. Links
Unwraps links: the <a> tag goes, its text and inner elements stay.
<p>Read <a href="https://example.com" target="_blank">our guide</a> first.</p>
<p>Read our guide first.</p>
4. Tags with whitespace
Removes elements that contain only spaces or , such as the empty paragraphs Word leaves behind.
<p>First</p> <p> </p> <p> </p> <p>Second</p>
<p>First</p> <p>Second</p>
5. Classes and IDs
Removes class and id attributes from every element.
<p id="intro" class="lead text-muted">Lorem ipsum <span class="hl">dolor</span>.</p>
<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.
<ul> <li>One</li> <li>Two</li> </ul>
<ul> <li>One</li> <li>Two</li> </ul>
7. Tables
Deletes tables together with everything inside them.
<p>Before</p> <table><tr><td>1</td><td>2</td></tr></table> <p>After</p>
<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.
<a href="/x" class="c" target="_blank"><img src="i.png" alt="Logo" width="10"></a>
<a href="/x"><img src="i.png"></a>
9. Span tags
Unwraps <span> elements and keeps their text.
<p><span style="font-family:Arial">Lorem</span> <span class="x">ipsum</span></p>
<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.
<p>Text<b></b></p> <div><span></span></div> <a name="top"></a>
<p>Text</p> <a name="top"></a>
11. Forms
Deletes <form> elements with their content, plus stray inputs, selects, textareas and buttons.
<p>Subscribe:</p> <form action="/s"><input name="email"><button>Go</button></form>
<p>Subscribe:</p>
12. JS code scripts
Removes <script> blocks, on* event attributes and javascript: links.
<p onclick="track()">Hi</p> <script>alert(1)</script> <a href="javascript:void(0)">Menu</a>
<p>Hi</p> <a>Menu</a>
13. Comments
Removes HTML comments, including Word conditional comments like <!--[if mso]>.
<!-- header --> <p>Lorem ipsum</p> <!--[if mso]><p>Outlook only</p><![endif]-->
<p>Lorem ipsum</p>
14. Non-breaking spaces
Replaces with a normal space, so words never get glued together.
<p>Lorem ipsum dolor</p>
<p>Lorem ipsum dolor</p>
15. Images
Deletes <img> and <picture> elements.
<p>Logo: <img src="logo.png" alt="Logo"> Company</p>
<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.
<h1>Title</h1> <p>Fish & chips<br>Daily</p> <script>x()</script>
Title Fish & 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 © change to © after cleaning?
The cleaner parses HTML into a DOM and writes it back, converting named entities such as © 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 &. Use HTML to Text if you need plain text without HTML escaping.