docx
Easily generate and modify .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
A JavaScript and TypeScript library that generates and edits Word (.docx) documents entirely in code, no Microsoft Word required, working in both Node.js and the browser.
docx is a JavaScript and TypeScript library for creating and editing Word documents (.docx files) in code, without needing Microsoft Word installed. You describe the document structure using the library's API, and it produces a proper .docx file that Word, Google Docs, or any compatible application can open.
The library works in two environments: Node.js, for server-side scripts and back-end applications, and directly in the browser, for web apps that need to generate downloadable Word files on the client side. Demos show it working inside React, Angular, and Vue.js projects, so it fits into the most common web frameworks without extra setup.
In terms of what you can build, the demos cover paragraphs, formatted text, bullet lists, tables, images, page margins, landscape orientation, headers, and footers. More advanced examples are in the project's demo folder and full documentation lives at docx.js.org. There is also an interactive playground called Docx.js Editor where you can write code and see the resulting document preview in real time, which is useful for experimenting with the API before adding it to a project.
The library is available through the npm package registry under the name docx and is used by a number of companies listed in the README, including Proton Mail and Dabble Writer. The README points to the documentation site for detailed usage instructions rather than reproducing them inline.
Where it fits
- Generate downloadable Word documents from a React, Angular, or Vue web app without a back-end service
- Create formatted Word reports with tables, images, headers, and footers from a Node.js script
- Build a server-side document generator that produces .docx files for bulk download or email attachment
- Try the API in the interactive Docx.js Editor playground before integrating it into a project