🧹

How to Clean Up Messy HTML from Word and Google Docs

Quick answer: HTML copied from Word or Google Docs carries the app's own formatting system along with it — inline styles, font tags, and (in Word's case) Microsoft-specific XML tags like <o:p>. The fastest fix for a paragraph or two is paste-without-formatting (Ctrl+Shift+V or Cmd+Shift+V). For anything longer, or anything with headings and lists you need to keep, strip the markup with a script or a dedicated cleaning tool instead of retyping it.

Why does content pasted from Word or Google Docs come out so messy?

Word and Google Docs aren't writing HTML for a website. They're exporting their own internal formatting model, and HTML happens to be the format they use to do it. Every font size, margin, and indent level in your document gets written out as an inline style attribute so the copy looks identical wherever it lands. Word goes further and adds its own XML namespace tags on top of that, because it's really exporting an Office Open XML fragment wrapped in HTML clothing.

None of that markup means anything to your CMS. It just sits there, usually overriding the CSS your site already has, which is why pasted content often shows up in the wrong font, at the wrong size, or with strange spacing that no amount of clicking "clear formatting" seems to fully remove.

What does the actual markup look like?

Paste one sentence from Word into a plain text editor and view it as HTML, and you'll typically see something close to this:

<p class="MsoNormal" style="margin:0in;font-size:11pt;font-family:Calibri">
  <span style="font-size:11.0pt">Hello World<o:p></o:p></span>
</p>

Three things are worth noticing. The MsoNormal class is Word's own default paragraph style, meaningless outside Word. The inline style attribute hardcodes a font and size that has nothing to do with your site's design system. And <o:p></o:p> is an empty Office namespace tag with no visual effect at all — it's just there because Word puts it there. A full page usually adds MSO conditional comments too, wrapping blocks like <!--[if gte mso 9]>...<![endif]-->, which are invisible in a browser but bulk up the source considerably.

Google Docs is cleaner but not clean. It skips the XML namespace tags and MSO comments, but still wraps text in <span style="..."> for every run of formatting, which adds up fast in a document with any mix of bold, links, and different font sizes.

How do you clean it up by hand?

For a sentence or two, paste-without-formatting handles it. Word, Docs, and most browsers support Ctrl+Shift+V (Cmd+Shift+V on a Mac) as a paste-as-plain-text shortcut, which drops every inline style along with any real HTML structure. That's the tradeoff: your bold and headings go with it, so you're retyping any formatting you actually wanted to keep.

For more than a paragraph, or anything with headings, links, or lists you want to preserve, hand-editing gets slow fast. A find-and-replace pass in a code editor can strip style="..." attributes and class="Mso..." in a couple of regex passes, but Word's markup is inconsistent enough (styles wrapped across multiple <span> tags, conditional comments nested at different depths) that a plain regex will miss edge cases a real HTML parser wouldn't.

Free Web Design & Marketing Guides. Practical guides on web performance, SEO, and getting more from your website — no email gate. Browse the Guides →

How do you clean it up with a tool?

A parser-based cleaner handles this more reliably than regex, because it reads the pasted content as an actual document instead of a string of text. It can walk every element, strip Word's namespace tags and inline styles, unwrap empty formatting spans, and leave your headings, links, bold, and lists intact. That's what the Word to HTML Cleaner does — paste, click, and the MSO scaffolding is gone while the structure stays. It runs entirely in your browser, so nothing you paste is uploaded anywhere.

The same underlying engine handles tables pasted from Excel or Google Sheets, which pick up nearly identical clutter — see the HTML table cleaner if that's what you're dealing with.

Frequently asked questions

Why does Word or Google Docs content look broken once it's on my site?

Word and Google Docs export their own formatting system as HTML — font sizes, margins, and list numbering are all rebuilt with inline styles and Microsoft-specific tags instead of the CSS your site already has. The two formatting systems fight, and your site's styles usually lose.

Does Ctrl+Shift+V (paste without formatting) fix this?

It fixes most of it. Paste-without-formatting strips inline styles and font tags, but it also strips real structure — headings become plain paragraphs, and links usually survive but bold and italics don't always. It's a good option for a paragraph or two of body text, not when the source has headings, lists, or links you want to keep.

Is it safe to paste a client's Word document into an online tool?

Depends on the tool. Anything that processes your paste in the browser with JavaScript, without sending it to a server, never has your content leave your machine. Check for that before pasting anything sensitive.

HTML & CSS Cleaner Tool

As web developers and designers, we often encounter HTML files laden with inline styles—those pesky CSS rules embedded directly within HTML tags. While this approach might seem convenient at first, it can lead to bloated code, slower page load times, and maintenance headaches. Fear not! Our HTML and CSS Cleaner Tool comes to the rescue. Whether you’re a seasoned developer or just starting your web journey, understanding the importance of clean HTML and CSS is essential.

Built and maintained by Bootstrap Creative, a web design and marketing agency for B2B and manufacturing companies. · Blog