Convert DOCX to Clean HTML

Turn a Word document into clean, semantic HTML to paste into a CMS or save as a web page. Your file stays in your browser.

Drop a .docx file here or choose one

Press Enter or click to browse. Nothing is uploaded.

How to convert a DOCX file to HTML

  1. Drop a .docx file on the dashed box, or press Enter on it to choose one. No file handy? Select Try a sample .docx.
  2. Check the Preview and read any Conversion notes from Word that appear.
  3. Choose your options: Include images (embedded in the HTML), Indent the code, and Output as an HTML fragment (for a CMS) or a Full web page.
  4. Open HTML code, then select Copy HTML or Download .html.

How the conversion works

A .docx file is a ZIP package of XML. The converter, mammoth.js 1.13.0, reads the paragraph styles and text formatting and maps them to HTML: Heading 1 to 6 styles become h1 to h6, numbered lists become ol, bulleted lists become ul, bold becomes strong and italic becomes em. Tables, links, footnotes and images carry over. The result is then cleaned with DOMPurify 3.4.16 and, if you keep Indent the code ticked, indented for reading. The Word format itself is standardized as ECMA-376 (ISO/IEC 29500).

Worked example

Select Try a sample .docx. It is a Word file with a Heading 1 reading "Quarterly Report", one paragraph with a bold word and an italic word, and a two-item bulleted list. With the defaults (images included, code indented, HTML fragment), the tool reports "Converted 13 words, 1 heading, 1 paragraph, 1 list. The HTML is 159 B." and the HTML code view shows:

<h1>Quarterly Report</h1>
<p>This paragraph has <strong>bold</strong> and <em>italic</em> text.</p>
<ul>
  <li>First bullet</li>
  <li>Second bullet</li>
</ul>

Limits and edge cases

Frequently asked questions

Why is my converted HTML missing fonts, colors and spacing?

The converter keeps the meaning of your document, not its looks. Headings, lists, bold, italic, links, tables and images carry over, while fonts, colors, sizes, margins and table borders are dropped so the code stays clean. Underlining is dropped too, because on a web page it looks like a link. Add your own CSS, or pick Full web page for a basic readable style.

How do I convert an old .doc file to HTML?

Open the file in Word or LibreOffice, choose Save As and pick Word Document (.docx), then upload that copy. The converter cannot read the old binary .doc format or password-protected files.

What happens to the images in my Word file?

Each image is embedded in the HTML as a base64 data URI, so the result is one self-contained file. That can make the HTML large. Untick Include images to leave them out, which is handy when your CMS wants images uploaded separately.

Is the HTML safe to paste into my website?

It is cleaned before you see it. Scripts, event attributes such as onclick and links that start with javascript: or data: are removed, so the output cannot run code. Review the text itself as you would any pasted content.

What happens to footnotes, comments and text boxes?

Footnotes and endnotes become a numbered list at the end with links back to the text. Comments are ignored. The contents of a text box appear as a separate paragraph after the paragraph that held the box.

Sources: mammoth.js documentation; ECMA-376 Office Open XML (ISO/IEC 29500); DOMPurify documentation.