Copy one paragraph out of Word. The clipboard now holds a whole document: a head, an XML settings block, a stylesheet, then your sentence inside two or three spans.
Paste the result into WordPress, a Shopify description, or a help-desk article. Every span comes along. The page looks fine in the editor. The source is a mess. The font no longer matches your theme. The next person to edit the post inherits mso-fareast-font-family on every line.
The sample above is a real-shaped Word 365 paste: release notes for the Toolexe JSON beautifier, one heading, one paragraph, a bulleted list with a nested point, a contact line. 3.1 KB of source. Defaults return 13 lines of plain tags, 572 bytes, 82% lighter. The ledger under the rules shows where each change came from.
<p class=MsoNormal><span style='mso-fareast-font-family:"Times New Roman"'>The
<b>JSON beautifier</b> at <a href="https://toolexe.com/json/beautifier"><span
style='color:#0563C1'>toolexe.com/json/beautifier</span></a> keeps key order when
you sort arrays.<o:p></o:p></span></p>
<p>The <strong>JSON beautifier</strong> at <a href="https://toolexe.com/json/beautifier">toolexe.com/json/beautifier</a> keeps key order when you sort arrays.</p>
Eight things Word put on your clipboard
Read the sample source top to bottom. Each item below is one line of junk, with the rule responsible for removing the line.
xmlns:oplusxmlns:won the html tag. Office namespaces. No browser reads them. Return the body only drops the html shell with the head inside.- A
File-Listlink toC:/Users/wajahat/AppData/Local/Temp/msohtmlclip1, a temp folder on the author's own disk. Shipping the link leaks a Windows username. The link goes with the head. With Return the body only unticked, Delete script, style, link, meta catches the link instead. - A conditional comment,
<!--[if gte mso 9]>, holding an XML settings block. Only Outlook's Word engine reads those. Inside the body, Delete comments removes theStartFragmentmarkers plus the<![if !supportLists]>pair around each bullet. Ten comments in the sample. class=MsoNormalon every paragraph. The stylesheet behind the class stays in Word, so on your site the class points at nothing.mso-declarations inside style attributes. Browsers skip all of them. With styles kept, the office rule strips only the mso- part.<o:p></o:p>closing every paragraph. A blank line in Word is<p class=MsoNormal><o:p> </o:p></p>, which Delete empty elements removes.- Bullets as fake paragraphs. Each bullet is a p with a negative indent, a Symbol-font middle dot, plus seven no-break spaces inside
<![if !supportLists]>. Not a list. <a name="_GoBack"></a>, a bookmark Word drops at the spot you last typed. Empty, so the empty rule deletes the anchor.
Word bullets come back as a real list
Pasted Word bullets render as indented paragraphs. Screen readers announce no list. Your theme's list styles never apply. Most cleaners strip the styles, leave the paragraphs, keep the middle dot as a stray character.
The rebuild rule reads two values out of each paragraph's mso-list declaration before any style is deleted. level1 or level2 sets the nesting depth. The hidden marker text picks the tag:
1.,a),iv.become anol.- A Symbol dot, a Courier
o, a Wingdings square become aul.
In the sample, "A trailing comma gets its own message" sits at level 2, so the rebuild nests a second ul inside the "Parse errors" item.
The limit: the rule ignores the number Word started from. A list continued from an earlier section restarts at 1. I check every ordered list against the Word file before publishing. Numbering is where a paste goes wrong without any visible error.
Google Docs breaks somewhere else
Docs exports real ul plus li tags, so the list rule has nothing to rebuild. The mess sits in three other places.
- The whole paste sits inside
<b style="font-weight:normal;" id="docs-internal-guid-...">. A naive b-to-strong rename turns the entire document into one strong tag. The office rule unwraps this wrapper first. - Every paragraph carries
dir="ltr". Redundant on a left-to-right page. Removed. Adir="rtl"stays. - Bold is not a b tag. Docs writes
font-weight:700on a span with ten other declarations.
A blind style purge turns every bold word in the Doc plain. Keep styled bold or italic wraps those spans in strong or em before the style rule runs:
<b style="font-weight:normal;" id="docs-internal-guid-6c1e2f0a-7fff">
<p dir="ltr" style="line-height:1.38;margin-top:0pt;">
<span style="font-size:11pt;font-family:Arial;font-weight:700;">Deadline:</span>
<span style="font-size:11pt;font-family:Arial;font-weight:400;"> Friday 18:00 UTC</span>
</p></b>
<p><strong>Deadline:</strong> Friday 18:00 UTC</p>
Paste the Docs snippet above into the source box to check the result yourself.
The order the rules run in
Ticking boxes in a different order changes nothing. The pass always runs the same sequence, because several rules read data a later rule deletes.
- Lists first. The rebuild needs
mso-listfrom the style attribute. - Comments, then script, style, link, meta, with on* handlers plus
javascript:links. - Office leftovers. The Docs wrapper has to go before b becomes strong.
- Styled bold or italic, then style attributes. Bold is saved from the style, then the style goes.
- class, id, presentational attributes.
- Unwrap. A span counts as bare only once its attributes are gone, so this step waits for the attribute rules.
- b to strong, i to em. An i with no text, such as an icon-font tag, keeps its name.
- Empty elements, near the end, since unwrapping exposes new empties.
- swap, then printing with or without indentation.
Pick boxes by where the HTML lands
| Destination | Change from defaults | Reason |
|---|---|---|
| WordPress, Ghost, Shopify rich text | None | The theme styles plain tags. Inline color or font from Word fights the theme. |
| HTML email template | Untick Delete style attributes plus presentational attributes | Outlook desktop renders with Word's engine. Inline styles, table width, bgcolor, cellpadding still carry the layout there. |
| Static site with your own CSS | Tick Delete id attributes | Pasted ids such as _Toc84211 or Docs heading ids collide with your own anchors. |
| Page using icon fonts | Untick Delete class attributes | An icon tag like <i class="fa fa-check"> is nothing without the class. |
| Markdown next | None, then HTML to Markdown | Converters choke on spans. Clean tags convert line for line. |
| Prices, units, names | Leave Swap off | The sample's 5 MB keeps the number glued to the unit at a line break. Word's junk no-break spaces sit in empty paragraphs plus bullet spacers, which other rules remove anyway. |
What the cleaner leaves alone
- Image paths. Word writes
src="file:///C:/Users/.../clip_image002.png", a file on your disk. The src stays as written, so the preview shows a broken image. Upload the images, then fix each src. Docs pastes inline base64 images instead. One full-screen screenshot often runs past 400 KB of text. - Image width plus height. Kept on img, video, iframe. The browser uses them to reserve space before the file loads, which stops the page from jumping.
- Minority lang attributes. Word stamps
lang=EN-USon spans everywhere. The office rule removes the most common lang value only, so anAR-SAquote inside an English document keeps its language mark for screen readers. - Empty elements with an id or class. An empty anchor with an id might be a link target. An empty
<i class="fa fa-check">is an icon. The empty rule skips both, as long as the class rule left the class in place. - Table cells. An empty td keeps the grid intact. colspan plus rowspan survive every rule.
- Your original nesting. The browser parser repairs broken markup on the way in. A p left open gets closed, a table gains a tbody. The output is the repaired tree, valid but not always shaped like the source.
Size, speed, privacy
Parsing runs in this tab through the browser's own HTML parser. Nothing reaches Toolexe. A refresh restores the Word sample, so copy the output first.
Auto-clean reruns 0.6 seconds after you stop typing, up to 500 KB of source. Above 500 KB, the page waits for the Clean button. A 150-page Word report pastes as 4 to 8 MB of HTML. Cleaning finishes, though the tab pauses for a few seconds on a mid-range laptop. Clean the document in chapters when the pause bothers you.
Wrong desk?
Use the HTML beautifier when the markup is already clean but unreadable. Indentation only, no rules. Run the HTML minifier after cleaning when bytes matter more than readability. Use HTML to Text when you want no tags at all. Check the result against the spec in the HTML validator.