🛠️

Export editable Word documents from semantic HTML with DOM-docx

DOM-docx converts semantic HTML fragments into native, editable .docx files, giving builders a lighter path for report exports, invoices, and creator documents than screenshot-style rendering.

Jul 14, 2026
Status & Access
Current access and latest update details.
Access
Free
Updated
Jul 14, 2026, 12:53 PM

DOM-docx is a small MIT-licensed JavaScript library and CLI for turning semantic HTML fragments into native Word documents. It is useful when a product already renders reports, briefs, invoices, tables, or creator drafts as HTML but still needs a real .docx export that users can edit in Word.

npx dom-docx input.html -o output.docx
cat fragment.html | npx dom-docx - -o - > output.docx

The default path is intentionally lightweight: inline styles convert in pure JavaScript, with no browser or Playwright dependency for normal Node usage. If you need class-based or computed CSS, the project supports an optional computed-style path using Playwright and Chromium. For browser apps, the package also exposes a browser bundle that can create a Blob in the user's tab.

What makes this worth bookmarking is the practical scope. The project supports headings, paragraphs, lists, tables, links, inline formatting, simple SVG, page metadata, headers, footers, page numbers, and image handling through an explicit resolver. It also documents the limits clearly: external stylesheets on the inline path, complex layout, web fonts, forms, and guaranteed multi-page fidelity are not solved yet.

Best fit

  • SaaS report exports where HTML is already the source of truth.
  • Internal tools that need editable Word handoff instead of PDF-only output.
  • Creator workflows that generate briefs, scripts, proposals, or tables from templates.
  • Agent-generated documents where a semantic HTML intermediate is easier to inspect than OOXML.

Caveats before shipping

  1. Treat untrusted HTML as input data and sanitize it before conversion.
  2. Use an allowlisted imageResolver for remote images, because the library does not fetch remote images by default.
  3. Test real customer documents in Word and LibreOffice before promising layout fidelity.
  4. Use the computed-style path only when you actually need stylesheet or class resolution.
Discussion

Sign in to join the discussion and vote on comments.

No comments yet. Start the discussion.
Keep exploring

More from this topic

More in Tools & Apps