Command line

word2html [-h] [--version] [--strict] [--timeout SECONDS]
          [--max-memory SIZE] [--max-file-size SIZE] path

Options

OptionDefaultWhat it does
pathRequiredThe .docx file to convert. The extension isn't case-sensitive.
--strictOffRefuse documents with unsafe links or hidden text instead of warning. See Security.
--timeout SECONDS120Stop pandoc after this long. Decimals are allowed.
--max-memory SIZE2GMemory limit for pandoc. The minimum is 16M.
--max-file-size SIZE200MThe largest input file to accept.
--versionShow the version and exit.
-h, --helpShow help and exit.

SIZE is a whole number with an optional unit: K, M, or G, such as 512M or 2G. A number alone means bytes. Units are powers of 1024, and 512MB and 512MiB both mean the same as 512M.

Exit codes

CodeMeaningOutput file
0Converted. Any warnings were printed to stderr.Written
1Invalid input, a limit was exceeded, or pandoc or the file write failed.Not changed
2Bad command line.Not changed
3Refused for safety.Not changed

The output file

The success message goes to stdout. Warnings and errors go to stderr, so you can separate them in scripts.

What's kept and what isn't

In the Word documentIn the HTML
Text, headings, lists, tables, links, footnotes, highlightsKept
Embedded images, PDFs, video, audioEmbedded in the HTML, so output can be larger than the .docx
Linked images, stored outside the documentDropped with a warning, and never fetched
Tracked insertionsPublished as if accepted
Tracked deletionsDropped
CommentsDropped
Paragraphs in Word's Title, Author, and Date stylesKept, and also used for the page's metadata
Document properties, set in File › InfoNot published
Hidden textPublished as visible text, with a warning. See Security.

Styling comes from pandoc's default CSS rather than the Word document, so fonts, colours, and page layout won't match the original.

Recipes

Convert a folder of documents

Use --strict and track failures, so one bad document doesn't go unnoticed:

status=0
for doc in ./*.docx; do
  word2html --strict "$doc" || status=1
done
exit "$status"

The ./ matters: it stops a file named something like --strict.docx from being read as an option.

Convert a file whose name starts with a dash

word2html ./-draft.docx
word2html -- -draft.docx

Act on the result in a script

word2html --strict "$doc"
case $? in
  0) echo "converted" ;;
  3) echo "refused: needs a human to review it" ;;
  *) echo "failed" ;;
esac

Convert untrusted documents on a shared machine

word2html --strict --timeout 30 --max-memory 512M --max-file-size 25M upload.docx

Then read Converting documents you don't trust, because these checks aren't a complete sanitizer.

Convert a very long document

word2html --max-memory 8G --timeout 600 book.docx