Generate Office Open XML
documents.
Create
.docx, .pptx, and .xlsx files programmatically with a declarative TypeScript API. Works in Node.js and browsers.import { Document, Packer, Paragraph, TextRun } from "@office-open/docx";
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [new TextRun({ text: "Hello, World!", bold: true })],
}),
],
},
],
});
const buffer = await Packer.toBuffer(doc);
pnpm add @office-open/docx
Declarative API
Describe document structure with intuitive TypeScript classes. Each element maps to valid OOXML markup.
Rich Content
Paragraphs, tables, images, charts, SmartArt, math equations, headers, footers, and more.
Type-safe
Full type definitions and autocomplete out of the box. No additional
@types packages needed.Cross-platform
Works in Node.js and browsers. Export to Buffer, Blob, Base64, stream, or string.
OOXML Compliant
Generates files that fully comply with the ISO/IEC 29500 Office Open XML specification.
Modular Packages
Install only what you need — docx, pptx, xml, or core.
Build documents with TypeScript classes
Describe your document structure using intuitive classes. Each element produces valid OOXML markup — no XML wrestling required.
Create Word documents with paragraphs, tables, images, and charts
Create PowerPoint presentations with shapes, animations, and transitions
Export to Buffer, Blob, Base64, stream, or string
import { Document, Packer, Paragraph, TextRun } from "@office-open/docx";
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [new TextRun({ text: "Hello, World!", bold: true })],
}),
],
},
],
});
await Packer.toBuffer(doc);
import { Presentation, Slide, Shape, Paragraph, TextRun, Packer } from "@office-open/pptx";
const pres = new Presentation({
slides: [
new Slide({
children: [
new Shape({
x: 1,
y: 1,
width: 8,
height: 4,
paragraphs: [
new Paragraph({
children: [new TextRun({ text: "Hello, World!", fontSize: 32 })],
}),
],
}),
],
}),
],
});
await Packer.toBuffer(pres);
Read and inspect existing files
Parse existing
.docx and .pptx files into structured objects. Inspect document content, extract data, or use as a foundation for modifications.Read document structure, styles, and content
Support for both Node.js Buffer and browser File
Parse, modify, and re-export in a pipeline
import { parseDocx } from "@office-open/docx";
const { document, sections, paragraphs } = await parseDocx(buffer);
import { parsePptx } from "@office-open/pptx";
const { slides, shapes } = await parsePptx(buffer);