
Company News
Andrew Becherer Joins Socket as Chief Information Security Officer
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.
@office-open/docx
Advanced tools
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.
# Install with npm
$ npm install @office-open/docx
# Install with pnpm
$ pnpm add @office-open/docx
import { Document, Paragraph, TextRun, Packer } from "@office-open/docx";
import { writeFileSync } from "node:fs";
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [
new TextRun("Hello World"),
new TextRun({
text: " - Bold text",
bold: true,
}),
],
}),
],
},
],
});
const buffer = await Packer.toBuffer(doc);
writeFileSync("My Document.docx", buffer);
Check the demo folder for 100+ working examples covering every feature.
Performance comparison against original docx (9.6.1) package (higher ops/s is better, Windows 11 / Node 24).
DEFLATE = compressed (default), STORE = no compression. Both libraries use DEFLATE.
Create + toBuffer (end-to-end)
| Scenario | DEFLATE sync | STORE sync | DEFLATE async | STORE async | docx |
|---|---|---|---|---|---|
| Simple (2 paragraphs) | 300 ops/s | 2,370 ops/s | 367 ops/s | 2,577 ops/s | 153 ops/s |
| Styled paragraphs (20) | 449 ops/s | 2,145 ops/s | 520 ops/s | 2,047 ops/s | 208 ops/s |
| Table (10×5) | 522 ops/s | 1,850 ops/s | 451 ops/s | 1,818 ops/s | 196 ops/s |
| Full featured (header/footer/headings/table/paragraphs) | 382 ops/s | 1,099 ops/s | 384 ops/s | 1,054 ops/s | 168 ops/s |
Large Files — Create + toBuffer
| Scenario | DEFLATE sync | STORE sync | DEFLATE async | STORE async | docx |
|---|---|---|---|---|---|
| 2000 paragraphs | 43.3 ops/s | 62.7 ops/s | 19.8 ops/s | 64.9 ops/s | 24.2 ops/s |
| 200×10 table | 85.5 ops/s | 107.0 ops/s | 23.0 ops/s | 110.7 ops/s | 34.3 ops/s |
| 20 sections × 100 paragraphs | 47.9 ops/s | 73.7 ops/s | 20.4 ops/s | 76.3 ops/s | 20.4 ops/s |
Large File (~100MB) — Mixed Content
2000 paragraphs + 200 unique images (500KB each) + 100×10 table. Speedup is vs docx.
| Method | Speed | Speedup |
|---|---|---|
| DEFLATE sync | 0.34 ops/s | 1.1x |
| STORE sync | 0.34 ops/s | 1.1x |
| DEFLATE async | 0.38 ops/s | 1.2x |
| STORE async | 0.38 ops/s | 1.2x |
| docx | 0.31 ops/s |
FAQs
Generate, parse, and patch .docx documents with a declarative TypeScript API
The npm package @office-open/docx receives a total of 618 weekly downloads. As such, @office-open/docx popularity was classified as not popular.
We found that @office-open/docx demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.

Security News
npm confirmed a tooling bug incorrectly marked several one-character packages as security holders and said it was working on a rollback.