
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) | 395 ops/s | 3,024 ops/s | 414 ops/s | 3,078 ops/s | 201 ops/s |
| Styled paragraphs (20) | 597 ops/s | 2,315 ops/s | 604 ops/s | 2,453 ops/s | 247 ops/s |
| Table (10×5) | 460 ops/s | 1,984 ops/s | 597 ops/s | 1,961 ops/s | 212 ops/s |
| Full featured (header/footer/headings/table/paragraphs) | 381 ops/s | 1,294 ops/s | 418 ops/s | 1,324 ops/s | 193 ops/s |
Large Files — Create + toBuffer
| Scenario | DEFLATE sync | STORE sync | DEFLATE async | STORE async | docx |
|---|---|---|---|---|---|
| 2000 paragraphs | 49.0 ops/s | 67.4 ops/s | 20.8 ops/s | 66.6 ops/s | 26.2 ops/s |
| 200×10 table | 90.1 ops/s | 129.1 ops/s | 25.5 ops/s | 125.5 ops/s | 37.0 ops/s |
| 20 sections × 100 paragraphs | 47.4 ops/s | 83.4 ops/s | 23.3 ops/s | 85.7 ops/s | 28.0 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.35 ops/s | 1.2x |
| STORE sync | 0.36 ops/s | 1.2x |
| DEFLATE async | 0.40 ops/s | 1.3x |
| STORE async | 0.39 ops/s | 1.3x |
| docx | 0.30 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.