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
TypeScriptMITCreated 2016-03-26docx.js.org/
Download: 9.15.49.15.4 ↓9.15.42026-11-14
+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

Latest release

9.15.4 9.15.4 2026-11-14
9.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

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON