ToolLineup

HTML Cleaner

This HTML cleaner removes the noise that word processors leave behind. Pasting from Word or Google Docs produces markup full of conditional comments, o: and w: namespace elements, Mso class names, inline styles pinned to point sizes, and empty wrappers nested several deep — all of which fight whatever styling your site actually uses. Every one of those is removed here, along with deprecated tags such as font and center, whose content is kept while the tag itself goes. Scripts and inline event handlers are removed by default too, since pasted markup is the most common route by which hostile HTML gets into a page. Each cleanup step is a separate toggle, so you can keep whatever you need.

How it works

Strips the noise out of markup pasted from Word, Google Docs or a WYSIWYG editor: conditional comments, o: and w: namespace elements, Mso class names, inline styles, empty wrappers and deprecated tags such as <font> and <center>.

Scripts and inline event handlers are removed by default, because pasted markup is the most common way hostile HTML gets into a page.

Everything runs in your browser — nothing you paste is sent to a server.

HTML input
Paste HTML here…
Cleaned HTML

How to clean HTML

  1. Paste the markup — typically copied out of Word, Google Docs or a WYSIWYG editor — into the input.
  2. Tick the cleanups you want; the count under the output says what was removed.
  3. Copy the cleaned markup, or download it as an .html file.

What Word actually pastes

Copying a paragraph out of Word can produce several hundred characters of markup for a single sentence. The bulk of it is bookkeeping that means nothing in a browser:

  • Conditional comments — <!--[if gte mso 9]> — wrapping XML islands.
  • Namespace elements such as <o:p> and <w:WordDocument>.
  • Class names beginning Mso, referring to styles that do not exist on your site.
  • Inline styles pinning font sizes in points and margins in centimetres.
  • Empty <span> and <div> wrappers nested several deep.

Left in place, all of it fights whatever styling your site actually uses — which is why pasted content so often looks subtly wrong.

Why empty-element removal repeats

Removing an empty <span> often leaves its parent <div> empty too. A single pass would clear one layer and stop, so the process repeats until nothing further is found.

Table cells are deliberately exempt. An empty <td> is structurally load-bearing — removing it would shift every cell after it into the wrong column.

Scripts and handlers go by default

Pasted markup is one of the most common routes by which hostile HTML reaches a page. <script> blocks and on* attributes are removed unless you explicitly keep them. As with any client-side cleanup, treat this as one layer rather than the whole defence — sanitise on the server too.

Common use cases

  • Cleaning a document before pasting it into a CMS.
  • Rescuing content from an old page full of <font> tags.
  • Removing inline styles so your stylesheet can take over.

Frequently asked questions

How do I clean HTML?

Paste your markup into the left panel and tick the cleanups you want. The result appears on the right with a count of what was removed.

What exactly does the Word cleanup remove?

Conditional comments, o: w: and v: namespace elements, xmlns and lang attributes, and class names beginning with Mso — all of which are Word bookkeeping that means nothing in a browser.

Why remove empty elements?

Word and WYSIWYG editors leave behind empty spans and divs that add nothing but can still pick up CSS rules and affect spacing. Removal repeats until nothing more is found, because emptying one wrapper often leaves its parent empty too.

Are table cells removed when empty?

No. An empty td or th is structurally necessary — removing it would shift every cell after it. Void elements like img and br are kept for the same reason.

Why are scripts removed by default?

Pasted markup is a common way hostile HTML reaches a page. Removing script tags and on* handlers by default is the safer starting point; untick the option if you genuinely need them.

Is my content uploaded?

No. Cleaning happens entirely in your browser.

Related tools