← Back

Word to HTML

Convert while keeping headings, bold and lists

Conversion preserves basic structure — headings, paragraphs, bold, italic and lists — but not exact fonts, colors, spacing or other fine-grained styling from the original document. Everything runs locally in your browser, and your file is never uploaded.

About Word to HTML

Word to HTML converts a .docx document into HTML code. After you choose a file, the page shows a rendered preview followed by the HTML source, which you can copy with 'Copy code' or save with 'Download .html'. It keeps basic structure such as headings, paragraphs, bold, italic, lists, links and tables, but not exact fonts, colors or spacing. The displayed and copied output is a fragment of the document body; the downloaded file adds a minimal doctype, charset declaration and title, but no stylesheet. Only .docx is supported; an older .doc file must first be re-saved as .docx in Word.

How to use it

  1. Click the dashed box 'Click to select a .docx file' and choose the document to convert.
  2. The page shows 'Converting…', and then a 'Preview' area appears on a white background showing how the converted HTML renders.
  3. After checking the preview, look at the 'HTML source' area. 'Copy code' copies it and 'Download .html' saves a file named after the original with .html added.
  4. Paste the code into a web editor, an email template or the source mode of a content management system.

A worked example from real output

We ran generated .docx test documents through the same conversion library (mammoth). One had a Heading 2, a tiny 1×1 pixel image, a line with a hyperlink, and a Heading 3. The result: the Heading 2 became an h2 tag and the Heading 3 an h3 tag; the hyperlink became an a tag with an href; underlined text lost its underline; struck-through text became an s tag; and the image was embedded by default as an img tag whose src is a long string starting with data:image/png;base64 (with 'Include images' unticked, no img tag is produced). A second document with a bullet list, a numbered list and a two-row, two-column table became ul, ol and table tags, with each table cell's text wrapped in a p tag and no th header cells. In short, structure is largely preserved, some details are dropped, and images make the code much longer.

Limits and known behavior

  • Only .docx is supported. An older .doc or an invalid file produces 'Could not convert this file. Please make sure you uploaded a valid .docx file (the older .doc format is not supported).'
  • Whether a line becomes h1, h2 and so on depends on whether you used Word's built-in Heading 1, Heading 2 styles. A normal paragraph that was merely enlarged and bolded stays a normal paragraph.
  • 'Include images' is ticked by default: images are converted to base64 and written directly into the HTML, so documents with many or large images produce very long code. Untick it to remove every img tag (no placeholder text is left); the conversion reruns immediately, and images are never exported as separate files.
  • Fonts, sizes, colors, line spacing, margins and underline are not preserved.
  • Tables become table tags, but without header cells or border styling, so on a web page they appear without lines unless you add CSS.
  • The output is sanitized with DOMPurify, which removes potentially dangerous content such as scripts, so a few unusual elements may be stripped.
  • The file from 'Download .html' is a complete web page (doctype, UTF-8 charset declaration and a title), so it opens correctly by double-click. 'Copy code' still copies only the body fragment, without that wrapper.
  • The preview box has a fixed maximum height, so long content scrolls inside it.

Why didn't my heading become an h1?

The conversion relies on paragraph styles in the Word document. Only paragraphs using the built-in Heading 1 to Heading 6 styles are recognised as headings. If you just made text bigger and bolder by hand, the tool cannot know it is a heading and outputs a normal paragraph. Reapply the styles from the Home tab's style gallery in Word and convert again.

Why is there a huge block of random-looking characters in the code?

That is an image (untick 'Include images' if you do not need it). Every picture in the document is encoded as base64 text and placed inside an img tag, so the HTML can show the image without a separate file. The price is longer code. If you plan to publish on a website, you will usually want to export the images separately and use normal image URLs.

Can I publish this HTML straight to my website?

Use it as a content fragment, not as a complete page. The copied code has no doctype, head or styling (the downloaded file has only a minimal wrapper, also unstyled), so you need to place it in your own page template and supply the CSS. Check the result in your site before publishing, especially tables and images.

Could the output contain scripts?

The converted code is passed through DOMPurify before it is shown and downloaded, which is meant to remove scripts and other risky content. Sanitizing is one layer of protection, though. If the document comes from an untrusted source, review the code yourself before putting it on a site.

How is this different from Word to Markdown?

Both first convert the document to HTML. This tool outputs the HTML directly, keeping things such as tables and strikethrough. Word to Markdown then converts that HTML into Markdown syntax, where tables end up as plain paragraphs. Use this one for web publishing, and the other for Markdown-based documents or note apps.

Privacy and processing

The file is read in your browser and converted locally by a library that the page loads on demand, and the sanitizing also happens locally. The code contains no network request that sends the document to a server. The result exists only on the current page and is gone when you close or refresh it.