
Security News
The Code You Didn't Write Is Still Yours to Defend
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.
@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 (Windows 11 / Node 22):
Object Creation (no pack)
| Scenario | @office-open/docx | docx | Speedup |
|---|---|---|---|
| Simple document (2 paragraphs) | 26.7K ops/s | 4.9K ops/s | 5.5x |
| Styled paragraphs (20 paragraphs) | 24.3K ops/s | 4.1K ops/s | 6.0x |
| Table (10x5 cells) | 17.8K ops/s | 3.0K ops/s | 5.9x |
| Full featured (header/footer/headings/table/paragraphs) | 13.1K ops/s | 2.4K ops/s | 5.5x |
Create + toBuffer (end-to-end)
| Scenario | @office-open/docx | docx | Speedup |
|---|---|---|---|
| Simple document (2 paragraphs) | 1,413 ops/s | 182 ops/s | 7.8x |
| Styled paragraphs (20 paragraphs) | 1,593 ops/s | 196 ops/s | 8.1x |
| Table (10x5 cells) | 1,167 ops/s | 174 ops/s | 6.7x |
| Full featured (header/footer/headings/table/paragraphs) | 784 ops/s | 162 ops/s | 4.8x |
Large Files — Create + toBuffer
| Scenario | @office-open/docx | docx | Speedup |
|---|---|---|---|
| 500 paragraphs | 182 ops/s | 84 ops/s | 2.2x |
| 100×10 table | 122 ops/s | 57 ops/s | 2.1x |
| 10 sections × 50 paragraphs | 267 ops/s | 103 ops/s | 2.6x |
FAQs
Generate, parse, and patch .docx documents with a declarative TypeScript API
The npm package @office-open/docx receives a total of 596 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.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.