Convert semantic HTML fragments to native, editable Word documents (OOXML): paragraphs, runs, lists, tables, images. Not screenshots or layout hacks.
Live demo: dom-docx.com. Try the converter, browse showcases, read the learn guide.
Built with a visual regression loop: render HTML in Chromium, convert to docx, rasterize via LibreOffice, score layout + structural fidelity against a human-validated metric, iterate. Latest scores: TEST-SCORES.md · methodology: SCORING.md.
Install
npm install dom-docx
Requires Node.js ≥ 20. No browser or Playwright is needed for the default inline path.
When is Playwright needed?
Entry styleSource: "inline" styleSource: "computed" rasterizeInPlace Node ( dom-docx ) Pure JS, no browser Playwright + Chromium Playwright + Chromium (same headless page) Browser ( dom-docx/browser ) Pure JS, no live DOM Live page: native getComputedStyle Live page: canvas/SVG → PNG <img> in the tab
On Node, playwright is an optional peer dependency. npm install dom-docx pulls only docx , cheerio and fflate , nothing heavy. It is loaded lazily when you pass styleSource: "computed" or rasterizeInPlace . To use those paths, install Playwright and Chromium yourself, once:
npm install playwright npx playwright install chromium
... continue reading