<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r" -->

---
title: GitHub - floodtide/dom-docx: Convert semantic HTML...
description: dom-docx is an open source npm library that converts semantic HTML fragments into native, editable Word documents (OOXML) — not screenshots or layout hacks. It...
canonical: https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: GitHub - floodtide/dom-docx: Convert semantic HTML fragments to native, editable Word documents (OOXML) | daily.dev
og:description: dom-docx is an open source npm library that converts semantic HTML fragments into native, editable Word documents (OOXML) — not screenshots or layout hacks. It...
og:url: https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r
og:image: https://api.daily.dev/og/posts/aZKfMwU3R.png
og:image:alt: GitHub - floodtide/dom-docx: Convert semantic HTML fragments to native, editable Word documents (OOXML)
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub - floodtide/dom-docx: Convert semantic HTML fragments to native, editable Word documents (OOXML)

**[Hacker News](https://daily.dev/sources/hn)** · 10 min read · 49 upvotes · 4 comments

## Summary

dom-docx is an open source npm library that converts semantic HTML fragments into native, editable Word documents (OOXML) — not screenshots or layout hacks. It supports headings, paragraphs, lists, tables, images, inline formatting, and more. The default inline path is pure JavaScript (no browser required), while an optional computed-styles path uses Playwright and Chromium for resolving CSS classes. A browser bundle is also available for client-side conversion. The library was built with a visual regression loop scoring layout fidelity, editability, and compile speed, and benchmarks against other html-to-docx libraries. The CLI, full API with options for page size, margins, fonts, headers/footers, cover pages, and table of contents are all documented.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://github.com/floodtide/dom-docx>

## Questions this post answers

### How can I convert an HTML fragment to a native, editable Word document in Node.js without using a browser?

The dom-docx npm package converts HTML fragments to native OOXML Word documents using a pure JavaScript path (docx, cheerio, fflate) with no browser needed, provided Node.js 20 or later is used. Install it with npm install dom-docx, then call convertHtmlToDocx(html), which returns a Promise<Buffer> ready to write as a .docx file.

_daily.dev surfaces practical library picks for developers automating Word document generation from HTML._

### What is the difference between styleSource inline and computed in dom-docx?

The inline styleSource parses only style="" attributes using pure JavaScript with no browser dependency, while computed uses getComputedStyle to resolve stylesheet and class/#id selectors. On Node, computed requires installing Playwright plus Chromium as an optional peer dependency to launch headless Chromium; in the browser bundle, computed styles are read directly from the live DOM with no Playwright needed.

_Choosing between style-resolution strategies matters when weighing HTML-to-docx tools on daily.dev._

### How do I convert charts made with canvas or Highcharts into a Word document?

Use the rasterizeInPlace option, which rasterizes canvas and complex SVG elements like Highcharts to PNG images before conversion, since complex SVG paths and gradients are not natively supported otherwise. The recommended setting is rasterizeInPlace: { scale: 2 } for sharper images in Word, with a default scale of 1 and a maximum of 4; in the browser this requires passing a root element.

_daily.dev helps developers compare approaches for exporting charts into editable Word documents._

## Community discussion

Top comments from developers on daily.dev.

**@sunyfilip** · 1 upvotes

> Why would you ever want that? 😅 🙈 ....create reverse tool 😁

**@trevorsuna** · 1 upvotes

> Native, editable OOXML is the important distinction here. Visual regression tests should ideally include a round trip through multiple consumers, because Word, LibreOffice, and Google Docs can normalize the same document differently after opening and saving it. Fidelity at generation time is only half the interoperability problem.

## Similar posts on daily.dev

- [eigenpal/docx-js-editor: WYSIWYG js DOCX editor](https://daily.dev/posts/eigenpal-docx-js-editor-wysiwyg-js-docx-editor-icamwgqqg) · Hacker News · 22 upvotes · 0 comments
- [How to Open and Render DOCX Files in the Browser with React](https://daily.dev/posts/how-to-open-and-render-docx-files-in-the-browser-with-react-pqjj5u0ed) · Syncfusion · 0 upvotes · 0 comments
- [Export Once, Share Everywhere: Convert DOCX to PDF, HTML, and More in React](https://daily.dev/posts/export-once-share-everywhere-convert-docx-to-pdf-html-and-more-in-react-yal6gpunb) · Syncfusion · 4 upvotes · 0 comments

---

Tags: [#typescript](https://daily.dev/tags/typescript)

[View this post on daily.dev](https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"GitHub - floodtide/dom-docx: Convert semantic HTML fragments to native, editable Word documents (OOXML)","url":"https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r"},"datePublished":"2026-07-13T13:33:23.048Z","dateModified":"2026-09-13T19:39:15.812Z","description":"dom-docx is an open source npm library that converts semantic HTML fragments into native, editable Word documents (OOXML) — not screenshots or layout hacks. It...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2ba8f37400ffe9110a586b0885284772?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/2ba8f37400ffe9110a586b0885284772?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Hacker News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hacker News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/hn","url":"https://daily.dev/sources/hn"},"commentCount":4,"discussionUrl":"https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":49},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":4}],"keywords":"typescript","timeRequired":"PT10M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hacker News","item":"https://daily.dev/sources/hn"},{"@type":"ListItem","position":3,"name":"GitHub - floodtide/dom-docx: Convert semantic HTML fragments to native, editable Word documents (OOXML)"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r","comment":[{"@type":"Comment","text":"Why would you ever want that? 😅 🙈 …create reverse tool 😁","datePublished":"2026-07-14T05:40:04.228Z","url":"https://daily.dev/posts/aZKfMwU3R#c-dWFDHm82B","author":{"@type":"Person","name":"Filip Januš","url":"https://daily.dev/sunyfilip","image":"https://lh3.googleusercontent.com/a/ACg8ocKAWfw1FGaQxjvEehprxNkdfgzHfwQJJW4g6qXZ0C9fkTpaZwQ=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"Native, editable OOXML is the important distinction here. Visual regression tests should ideally include a round trip through multiple consumers, because Word, LibreOffice, and Google Docs can normalize the same document differently after opening and saving it. Fidelity at generation time is only half the interoperability problem.","datePublished":"2026-07-15T01:50:38.847Z","url":"https://daily.dev/posts/aZKfMwU3R#c-7WxHqdnn2","author":{"@type":"Person","name":"Trevor Suna","url":"https://daily.dev/trevorsuna","image":"https://media.daily.dev/image/upload/s--dZ7gXxpp--/f_auto/v1784081551/avatars/avatar_EMoP47rpuw8DNjhp6R1b6?_a=BAMAMicg0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/github---floodtide-dom-docx-convert-semantic-html-fragments-to-native-editable-word-documents-oox-azkfmwu3r#faq","mainEntity":[{"@type":"Question","name":"How can I convert an HTML fragment to a native, editable Word document in Node.js without using a browser?","acceptedAnswer":{"@type":"Answer","text":"The dom-docx npm package converts HTML fragments to native OOXML Word documents using a pure JavaScript path (docx, cheerio, fflate) with no browser needed, provided Node.js 20 or later is used. Install it with npm install dom-docx, then call convertHtmlToDocx(html), which returns a Promise\u003cBuffer\u003e ready to write as a .docx file. daily.dev surfaces practical library picks for developers automating Word document generation from HTML."}},{"@type":"Question","name":"What is the difference between styleSource inline and computed in dom-docx?","acceptedAnswer":{"@type":"Answer","text":"The inline styleSource parses only style=\"\" attributes using pure JavaScript with no browser dependency, while computed uses getComputedStyle to resolve stylesheet and class/#id selectors. On Node, computed requires installing Playwright plus Chromium as an optional peer dependency to launch headless Chromium; in the browser bundle, computed styles are read directly from the live DOM with no Playwright needed. Choosing between style-resolution strategies matters when weighing HTML-to-docx tools on daily.dev."}},{"@type":"Question","name":"How do I convert charts made with canvas or Highcharts into a Word document?","acceptedAnswer":{"@type":"Answer","text":"Use the rasterizeInPlace option, which rasterizes canvas and complex SVG elements like Highcharts to PNG images before conversion, since complex SVG paths and gradients are not natively supported otherwise. The recommended setting is rasterizeInPlace: { scale: 2 } for sharper images in Word, with a default scale of 1 and a maximum of 4; in the browser this requires passing a root element. daily.dev helps developers compare approaches for exporting charts into editable Word documents."}}]}
```

