word2html

Convert a Word .docx file into one self-contained HTML5 file, with checks for malformed documents, unsafe links, and hidden text.

$ word2html report.docx
Done! Output written to: report.html

word2html runs pandoc to do the conversion. On top of that it checks the document before pandoc sees it, inspects the HTML that comes out, and only then writes the file.

Get started

  1. Install pandoc 3.6 or newer. It's a separate program that word2html doesn't install for you.
  2. Run word2html on a document:
    uvx word2html report.docx
  3. Open report.html, next to the original file.

What you get

What happens to risky content

Found in the documentBy defaultWith --strict
Unsafe links, such as javascript:Warns, then convertsRefuses
Text hidden in WordWarns, then convertsRefuses
Active content, such as an "image" that's really HTMLRefusesRefuses

By default, flagged links and hidden text still end up in the HTML. The warning is the only protection, so use --strict anywhere nobody reads stderr. Read the security guide before publishing HTML made from documents you didn't write.

Where to go next

InstallationInstall pandoc and word2html on your platform.
Command lineEvery option, exit code, and common recipe.
SecurityWhat's checked, what isn't, and how to handle untrusted documents.
Validation & limitsWhat gets rejected, and how to tune memory and time limits.
Python APIUse word2html from your own code.
TroubleshootingWhat each error means and how to fix it.
Upgrading from 0.4What changed, and what you may need to update.
DevelopmentRun the tests, understand the code, and contribute.