Skip to content

HTML Cleaner

✨ Cleans as you type 0 lines · 0 B

Clean HTML

Paste messy HTML on the left

Clean code shows up here as you type
Nothing to clean yet

HTML Cleaner: Remove Inline Styles, Classes and Junk Tags

What is an HTML Cleaner?

An HTML cleaner takes messy HTML and strips out the parts you don’t want, while keeping your content: the text, headings, lists, tables, links and images. Copy a few paragraphs out of a CMS, Word, Google Docs or an email builder, and you usually get a lot more than you asked for: style="..." on every tag, class names from someone else’s stylesheet, <span> inside <span>, empty paragraphs used as spacers, and comments nobody needs.

Paste it on the left and the clean version shows up on the right as you type. You pick what goes with a few checkboxes, or start from a preset. Everything runs in your browser, so your code never leaves your device.

How to Use It, Step by Step

Step 1 Paste or Open Your HTML

  • Paste it: a snippet or a whole page, both work.
  • Open a file: click the upload button or drag an .html file onto the page.
  • Sample: loads a messy page (Word leftovers, inline styles, a script) so you can see what happens.

Step 2 Pick a Preset, Then Fine-Tune

Click Options above the result. Choose a preset as a starting point, then tick or untick anything you like. The result updates right away, and your choices are remembered in this browser.

  • Light clean: Comments, empty tags, Word leftovers and extra spaces go. Styles and classes stay.
  • Strip all styling: Inline styles, classes, spans, fonts, <style> blocks and old look-only attributes go.
  • Text and links only: Only text, headings, lists, tables and links stay. Images, embeds and forms go too.
  • Word / Google Docs paste: For HTML copied from Word or Google Docs: their styles, spans and extra markup go.

Step 3 Check the Preview and the Summary

The Preview tab shows the clean HTML the way a browser draws it (scripts off). The Summary tab lists what was removed, with counts, for example “12 inline styles, 6 class attributes, 2 empty tags”, plus the size before and after.

Step 4 Copy or Download

Click Copy and paste the result where you need it, or Download it as an .html file. Under Options you can choose Indented output (2 spaces, 4 spaces or tabs) or One line if you want it compact.

What Each Option Does

Small before and after examples, each with only the named option ticked.

Inline styles

Before:

<p style="color: #333; font-size: 14px">Hello there</p>

After:

<p>Hello there</p>

Your own stylesheet takes over again, so the text matches the rest of your site.

Classes and IDs

Before:

<div class="card shadow-lg" id="promo-3">Sale ends Friday</div>

After:

<div>Sale ends Friday</div>

Class names from another site mean nothing on yours. Keep IDs if you link to #anchors on the page.

Other attributes

Before:

<td align="center" bgcolor="#eeeeee" colspan="2">Total</td>

After:

<td colspan="2">Total</td>

Old look-only attributes go. colspan stays, because it changes the table itself.

<span> and <font>

Before:

<p><font face="Arial"><span style="font-weight: bold">Big news</span> today</font></p>

After:

<p><strong>Big news</strong> today</p>

The tags go and the text stays. A span that made text bold becomes <strong>, so the bold isn’t lost.

Empty tags

Before:

<p>Hi!</p>
<p>&nbsp;</p>
<p><span></span></p>

After:

<p>Hi!</p>

Editors love adding empty paragraphs for spacing. Use CSS margins for that instead.

Word leftovers

Before:

<p class="MsoNormal" style="margin: 0in; mso-line-height-alt: 12pt">Hello<o:p></o:p></p>

After:

<p style="margin: 0in">Hello</p>

Only the Word-only bits go here. Tick Inline styles too if you want the margin gone as well.

Google Docs wrapper

Before:

<b style="font-weight:normal;" id="docs-internal-guid-1a2b"><p dir="ltr">Meeting notes</p></b>

After:

<p>Meeting notes</p>

Google Docs wraps every copy in a <b> that isn’t bold. Left alone, it can make the whole page bold.

Extra <br> and &nbsp;

Before:

<p>Line one<br><br><br><br>Line two&nbsp;&nbsp;&nbsp;here</p>

After:

<p>Line one<br><br>Line two here</p>

Up to two line breaks in a row stay. A single &nbsp; between words (like 10&nbsp;km) stays too.

<b> and <i> to <strong> and <em>

Before:

<p><b>Note:</b> this is <i>really</i> important</p>

After:

<p><strong>Note:</strong> this is <em>really</em> important</p>

They look the same, but screen readers and search engines read <strong> and <em> as real emphasis.

Always on: scripts, unsafe links and redirects

Before:

<a href="javascript:steal()" onclick="track()">Click me</a>
<script>alert("hi")</script>

After:

<a>Click me</a>

Scripts, event handlers, javascript: links, <base> tags and page redirects go even with every option off. Links and embeds to other sites stay, so check where they point.

The other options do what their names say: Comments removes <!-- ... --> (but keeps Outlook’s <!--[if mso]> conditional comments), <style> blocks removes <style> and stylesheet links, <iframe>, <object> / <embed> and Images and media remove those tags, Forms removes form fields but keeps labels and button words as plain text, and Body only drops the <html>, <head> and <body> wrapper so you get just the content. Hover over any option to see a short explanation.

When to Use It

What It Can’t Do

Frequently Asked Questions

How do I remove all inline styles from HTML?

Paste your HTML, open Options and tick Inline styles (the Strip all styling preset already has it on). Every style="..." attribute goes. If a <span> used a style to make text bold or italic, the text is wrapped in <strong> or <em> first, so it keeps that meaning.

Will cleaning change how my page looks?

Usually yes, and that’s often the point: the old colors, fonts and spacing go, and your own CSS takes over. Switch to the Preview tab to see the result before you copy it. If you only want to drop junk and keep the look, pick the Light clean preset.

Can it clean HTML pasted from Word or Google Docs?

Yes. The Word / Google Docs paste preset removes Word’s <o:p> tags, mso- styles, Mso classes and conditional comments, and the Google Docs wrapper that isn’t really bold. If you’d rather paste formatted text straight from Word and get HTML back, try our Word to HTML converter, which also rebuilds Word’s fake lists into real ones.

Does it remove scripts and onclick handlers?

Always, whatever options you pick. <script> and <noscript> blocks, event handlers like onclick and onload, javascript: links, <base> tags and page redirects (meta refresh) are removed every time. The cleaner also reads its own result back a few times to make sure no trick markup turns back into a script. Ordinary links, images and iframes to other sites stay unless you tick their options, so it’s still worth a look at where they point.

What’s the difference between the HTML Cleaner and the HTML Fixer?

The cleaner removes things you don’t want (styles, classes, junk tags). The HTML Fixer repairs mistakes (unclosed tags, wrong nesting) and lists what it fixed and what you still need to fix by hand. If your HTML is both messy and broken, run it through the fixer first, then clean it.

Why did my icons disappear?

Icon fonts often use empty tags like <i class="icon-home"></i>. Empty tags with a class or a style are kept while those are kept, but if you remove classes too, those tags are empty and unstyled, so they go. Untick Empty tags, or add class to Always keep.

Can I keep some attributes, like class or data-id?

Yes. Type them into Always keep in the options, separated by commas, for example "class, data-id". A * at the end matches the start of a name, so aria-* keeps every aria- attribute. Event handlers can’t be kept.

Should I strip inline styles from HTML emails?

No. Many email apps ignore <style> blocks, so emails rely on inline styles, plus old attributes like bgcolor and width on tables. Use the Light clean preset: it keeps all of those, keeps Outlook’s conditional comments (<!--[if mso]>) and keeps styled spacer boxes. Then check the result in our HTML Email Viewer.

Is my HTML uploaded anywhere?

No. Cleaning happens in your browser, and nothing you paste is sent to our server. Only your option choices are remembered in this browser, so they’re ready next time.

More Tools for Your HTML