docx2md
v1.0.0
Published
Convert .docx files to Markdown from the command line
Maintainers
Readme
docx2md
Convert .docx files to Markdown from the command line.
.docx → [mammoth] → HTML → [turndown] → .mdQuick Start
npm install -g docx2mddocx2md document.docx # → document.md
docx2md document.docx -o output.md # custom output path
docx2md document.docx --stdout # print to stdout
docx2md document.docx -i ./images # extract embedded imagesFeatures
- Headings —
h1–h6→#–######(ATX style) - Formatting — bold, italic, strikethrough,
code - Lists — bulleted
-and numbered1. - Links —
<a>→[text](url) - Images —
<img>→, with optional extraction - Tables — complex tables preserved as HTML (faithful layout)
- Code blocks — fenced with triple backticks
- Blockquotes —
>prefixed - Full CJK — Chinese, Japanese, Korean preserved without corruption
Pipeline
| Stage | Library | Role |
|-------|---------|------|
| Parse | mammoth | .docx → semantic HTML |
| Convert | turndown | HTML → Markdown |
| CLI | commander | args, help, version |
CLI Reference
Usage: docx2md [options] <input>
Arguments:
input Path to the .docx file to convert
Options:
-o, --output <path> Output markdown file (default: <input>.md)
-i, --images <dir> Extract embedded images to directory
--stdout Print markdown to stdout instead of file
-V, --version Show version
-h, --help Show helpDevelopment
git clone <repo>
cd docx2md
npm install
npm run dev -- document.docx # run without building
npm run build # compile TypeScript
npm test # run 25 unit + integration testsLicense
MIT
