# dom-docx
**Repository Path**: getpro/dom-docx
## Basic Information
- **Project Name**: dom-docx
- **Description**: No description available
- **Primary Language**: JavaScript
- **License**: MIT
- **Default Branch**: main
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2026-08-03
- **Last Updated**: 2026-08-03
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# dom-docx
Convert semantic **HTML** to native, editable **docx files** (OOXML): paragraphs, runs, lists, tables, flex and images are all supported.
**Live demo:** [dom-docx.com](https://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](./docs/TEST-SCORES.md) · methodology: [SCORING.md](./docs/SCORING.md).
## Install
```bash
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 `` 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:
```bash
npm install playwright
npx playwright install chromium
```
Playwright is also used by the **dev test harness** (not required to use the library). Contributors: `npm run setup` after clone.
LibreOffice is **not** needed to convert. It is only used for the visual test harness.
## Quick start
### Node
```typescript
import { writeFile } from "node:fs/promises";
import { convertHtmlToDocx } from "dom-docx";
const html = `
Revenue grew 12% year over year.
Revenue grew 12% year over year.