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
- Install pandoc 3.6 or newer. It's a separate program that word2html doesn't install for you.
- Run word2html on a document:
uvx word2html report.docx - Open
report.html, next to the original file.
What you get
- One file to share. Images are embedded in the HTML, so there's no folder of media to keep alongside it.
- Modern HTML. HTML5 with a declared UTF-8 charset, a page title, and pandoc's default styling. Tables, footnotes, and highlights are kept.
- Protection from bad input. Corrupt, oversized, and hostile files fail quickly with a clear error, and memory and time limits apply to pandoc itself.
- Safe file handling. Output is written atomically, so a failed run never damages an existing file.
- No Python dependencies. The only requirement besides Python is pandoc.
What happens to risky content
| Found in the document | By default | With --strict |
|---|---|---|
Unsafe links, such as javascript: | Warns, then converts | Refuses |
| Text hidden in Word | Warns, then converts | Refuses |
| Active content, such as an "image" that's really HTML | Refuses | Refuses |
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
| Installation | Install pandoc and word2html on your platform. |
| Command line | Every option, exit code, and common recipe. |
| Security | What's checked, what isn't, and how to handle untrusted documents. |
| Validation & limits | What gets rejected, and how to tune memory and time limits. |
| Python API | Use word2html from your own code. |
| Troubleshooting | What each error means and how to fix it. |
| Upgrading from 0.4 | What changed, and what you may need to update. |
| Development | Run the tests, understand the code, and contribute. |