dolanmiu /docx
Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
★ 6,002⑂ 624👁 47⑃ 2,666● 909▤ 109
+2
Daily
6,002
stars
624
forks
47
watchers
2,666
prs
909
issues
109
releases
README
Easily generate and modify .docx files with JS/TS. Works for Node and on the Browser.
---
[![NPM version][npm-image]][npm-url]
[![Downloads per month][downloads-image]][downloads-url]
[![GitHub Action Workflow Status][github-actions-workflow-image]][github-actions-workflow-url]
[![Known Vulnerabilities][snky-image]][snky-url]
[![PRs Welcome][pr-image]][pr-url]
[![codecov][codecov-image]][codecov-url]
[![Docx.js Editor][docxjs-editor-image]][docxjs-editor-url]
Demo
Browser
With basic HTML/JS in a browser, load docx's browser build, which defines a global docx:
html
Download a Word document
function generate() {
const doc = new docx.Document({
sections: [
{
children: [
new docx.Paragraph({
children: [new docx.TextRun("Hello World"), new docx.TextRun({ text: "Foo Bar", bold: true })],
}),
],
},
],
});
docx.Packer.toBlob(doc).then((blob) = {
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = "example.docx";
link.click();
});
}
Here are examples of docx working in Angular:
- https://stackblitz.com/edit/angular-docx
- https://stackblitz.com/edit/angular-wmd6k3
Here are examples of docx working in React:
- https://stackblitz.com/edit/react-docx
- https://stackblitz.com/edit/react-docx-images (adding images to Word Document)
Here is an example of docx working in Vue.js:
- https://stackblitz.com/edit/vuejs-docx
Node
Press endpoint on the RunKit website:
!RunKit Instructions
- https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
- https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
- https://runkit.com/dolanmiu/docx-demo3 - Bullet points
- https://runkit.com/dolanmiu/docx-demo4 - Simple table
- https://runkit.com/dolanmiu/docx-demo5 - Images
- https://runkit.com/dolanmiu/docx-demo6 - Margins
- https://runkit.com/dolanmiu/docx-demo7 - Landscape
- https://runkit.com/dolanmiu/docx-demo8 - Header and Footer
- https://runkit.com/dolanmiu/docx-demo10 - My CV generated with docx
More here
How to use & Documentation
Please refer to the documentation at https://docx.js.org/ for details on how to use this library, examples and much more!
Shapes, watermarks and charts
Shapes, groups of shapes and diagrams with connectors come with docx, from docx/shapes, watermarks from docx/watermarks, and native Word charts from docx/charts. They are left out of docx itself, so documents that don't use them don't carry their code:
ts
import { Document, Header, Paragraph } from "Top issues
Discussions
#3827We compared four markdown-to-Word paths. docx/html won.0 comments · 2026-10-23#3503json-to-office: documents as data, with docx as the Word renderer0 comments · 2026-08-23#3423docx-to-builder that takes a branded Word template and generates a ready-to-run docx.js builder from it0 comments · 2026-04-09#3324How can I use this locally, without Node?2 comments · 2026-01-16#3264Add sections after patchDocument1 comments · 2025-09-26#3239Consider Enabling Immutable Releases for Supply Chain Security0 comments · 2025-09-10#3233Bold Numbered Lists (Including the Number)1 comments · 2025-09-07#3223How to read an existing docx file, not to edit it?1 comments · 2025-08-26
Latest release
9.15.4 9.15.4 2026-11-149.15.4 is a maintenance release with no changes to the API. It updates the HTML parser that docx/html bundles (parse5 8.1.1) and the build tooling, so docx/html reads HTML with the latest parse5 fixes. What's Changed build(deps-dev): bump typescript-eslint from 8.72.1 to 8.72.2 by @dependabot[bot] in https://github.com/dolanmiu/docx/pull/3904 build(deps-dev): bump vite from 8.3.5 to 8.3.7 by @dependabot[bot] in https://github.com/dolanmiu/docx/pull/3901 build(deps-dev): bump parse5 from 8.1.0 to 8.1.1 by @dependabot[bot] in https://github.com/dolanmiu/docx/pull/3900 build(deps-dev): bump