Clean HTML pasted from Word, Google Docs or a page builder

Paste HTML exported from Word, an email editor or a page builder and the cleaner strips Office markup, inline styles, classes, event handlers, font tags and empty elements, leaving the content and its structure.

Live demo · real result from this tool

Clean HTML

<p><b>Quarterly update</b></p><p>Sales grew 12% this quarter.</p>
Attributes removed7
Elements removed or unwrapped
7

Processed on your device — nothing is uploaded.

How to use the HTML cleaner

  1. Paste the markup into the HTML box. The sample is a typical paragraph copied out of Word.
  2. Tick what to remove. By default the tool removes Word markup, inline styles, classes, on* event handlers, comments and empty elements, and unwraps font and bare span tags. Removing ids, data-* attributes and scripts is off until you tick it.
  3. Copy the Clean HTML or download it as clean.html.
  4. Check the counters: Attributes removed and Elements removed or unwrapped.

What it does and when to use it

Text copied from Word or Google Docs into a CMS often brings hidden baggage: class="MsoNormal", mso-line-height-rule, o:p tags, fonts and colours fixed in every span. That markup overrides your site’s CSS, bloats the page and makes later edits painful. The cleaner removes the presentation and keeps the meaning: paragraphs, headings, bold text, lists, links and tables.

It is also useful for markup copied from another website or an old template, where you want the text but not someone else’s classes, tracking attributes or inline click handlers.

How it works

The HTML is parsed into a tree in your browser. Each element’s attributes are filtered by the options you chose. After that, font elements and spans with no attributes are replaced by their contents. Finally, elements such as p, span, b or li that contain only spaces or &nbsp; are dropped. The tree is then written back out. Nothing is uploaded.

Worked examples

Word export, default options. The sample loses 7 attributes and 7 elements or comments. The result is:

<p><b>Quarterly update</b></p>
<p>Sales grew 12% this quarter.</p>

Keep styles and classes, drop only Word junk. Untick Remove inline styles and Remove class attributes. The mso- declarations go, but real CSS stays:

<p style="margin:0cm"><span style="font-family:Calibri"><b>Quarterly update</b></span></p>

The MsoNormal class still disappears, because it belongs to Word markup.

A promo block with a script. Input: a div with id, class and onclick, an empty p, a font tag and a script. With Remove <script>, <style>, <iframe> and embeds ticked, the output is <div id="promo">Spring sale</div>. The id stays because Remove id attributes is off.

Limits and tips

  • The cleaner does not fix broken nesting. Check the result with the HTML Validator.
  • To remove only a chosen list of attributes, such as class but not style, the HTML Attribute Remover gives finer control.
  • If you only need the words, the HTML to Text converter drops every tag.
  • Tables keep their structure, but Word’s widths and borders are inline styles, so they are removed with the styles.

Frequently asked questions

Will it remove my headings, lists and links?
No. Elements such as h2, ul, li, a, table and strong stay. Only the attributes you tick are removed, plus font tags, spans with no attributes left, and elements that end up empty. Links keep their href.
What counts as Microsoft Word markup?
Styles that start with mso-, classes such as MsoNormal, Office tags such as o:p and other w, v or m prefixed tags, xml blocks, xmlns and lang attributes, and conditional comments such as the if gte mso 9 block. With the Word option on but inline styles kept, only the mso- declarations are cut from each style.
Why did an empty paragraph stay?
Empty elements with an id or name attribute are kept, because something may link to them or script them. Tick "Remove id attributes", or delete the id yourself, if the element really is unused.
Does it remove scripts?
Only when you tick "Remove <script>, <style>, <iframe> and embeds". That option also removes object, embed and noscript. It is off by default so that you do not lose an embed by accident. On-event attributes such as onclick are removed by their own option, which is on by default.
Is the output indented?
The cleaner keeps your original line breaks and does not re-indent. Run the result through the HTML Formatter if you want tidy indentation.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close