The all-in-one TypeScript toolkit for Office documents. Generate, parse, and patch .docx, .pptx, .xlsx files — fully typed, spec-compliant, and works everywhere. Compatible with Microsoft Office, WPS Office, LibreOffice, and Google Workspace.
- 📄 All-in-One — Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) in one cohesive API, no Office dependency
- 📐 Spec-Compliant — Output validates against OOXML Transitional XSD schemas (ISO/IEC 29500), compatible with Microsoft Office, WPS Office, LibreOffice, and Google Workspace
- 🔒 Fully Typed — Complete TypeScript definitions with full autocomplete and type safety
- 🎯 Pure JSON API — Define documents as plain JSON objects, zero class instantiation, ideal for AI agents
- 🔄 Parse & Patch — Read existing .docx, .pptx, .xlsx files for round-trip workflows, or patch templates by placeholder replacement
- 🎨 Rich Content — Paragraphs, tables, images, charts, SmartArt, math equations, effects, animations, and more
- ⚡ High Performance — Optimized for large documents and batch processing with native zlib compression
- 🌐 Cross-Platform — Node.js, browsers, Deno, Bun. Export to Buffer, Blob, Base64, stream, or string
| Package | Version | Description |
|---|---|---|
| @office-open/docx | Word document generation, parsing, and patching | |
| @office-open/pptx | PowerPoint generation, parsing, and patching | |
| @office-open/xlsx | Spreadsheet generation, parsing, and patching | |
| @office-open/core | Shared OOXML infrastructure, charts, unit converters | |
| @office-open/xml | Low-level XML parsing and serialization | |
| office-open | Umbrella: all packages + CLI + AI SDK tools |
# pnpm
pnpm add @office-open/docx
# npm
npm install @office-open/docx
# yarn
yarn add @office-open/docx
# bun
bun add @office-open/docximport { generateDocumentSync } from "@office-open/docx";
import { writeFileSync } from "node:fs";
const buffer = generateDocumentSync({
sections: [
{
children: [{ paragraph: { children: [{ text: "Hello World", bold: true }] } }],
},
],
});
writeFileSync("document.docx", buffer);# pnpm
pnpm add @office-open/pptx
# npm
npm install @office-open/pptx
# yarn
yarn add @office-open/pptx
# bun
bun add @office-open/pptximport { generatePresentationSync } from "@office-open/pptx";
import { writeFileSync } from "node:fs";
const buffer = generatePresentationSync({
slides: [
{
children: [
{
shape: {
x: 100,
y: 100,
width: 600,
height: 400,
textBody: { children: [{ paragraph: { children: ["Hello World"] } }] },
fill: "4472C4",
},
},
],
},
],
});
writeFileSync("presentation.pptx", buffer);# pnpm
pnpm add @office-open/xlsx
# npm
npm install @office-open/xlsx
# yarn
yarn add @office-open/xlsx
# bun
bun add @office-open/xlsximport { generateWorkbookSync } from "@office-open/xlsx";
import { writeFileSync } from "node:fs";
const buffer = generateWorkbookSync({
worksheets: [
{
name: "Sheet1",
rows: [
{ cells: [{ value: "Name" }, { value: "Score" }] },
{ cells: [{ value: "Alice" }, { value: 95 }] },
{ cells: [{ value: "Bob" }, { value: 87 }] },
],
},
],
});
writeFileSync("workbook.xlsx", buffer);Install all packages at once with CLI, AI SDK tools, and schemas:
# pnpm
pnpm add office-open
# npm
npm install office-open
# yarn
yarn add office-open
# bun
bun add office-openimport { generate } from "office-open/generate";
import { writeFileSync } from "node:fs";
const buffer = await generate({
type: "docx",
options: {
sections: [{ children: [{ paragraph: "Hello from office-open!" }] }],
},
outputType: "nodebuffer",
});
writeFileSync("output.docx", buffer);# CLI usage
npx office-open xlsx input.json "output.xlsx"Read and inspect existing .docx, .pptx, and .xlsx files into structured objects:
// DOCX
import { parseDocument } from "@office-open/docx";
const opts = parseDocument(buffer);
// opts.sections — document sections
// opts.title, opts.creator — core properties
// PPTX
import { parsePresentation } from "@office-open/pptx";
const opts = parsePresentation(buffer);
// opts.slides — slide array
// opts.size, opts.title — presentation properties
// XLSX
import { parseWorkbook } from "@office-open/xlsx";
const opts = parseWorkbook(buffer);
// opts.worksheets — worksheet array
// opts.worksheets[0].rows — row/cell dataDefine documents as plain JSON objects — perfect for AI agents. Zero class instantiation, pure data in and binary out:
import { generateDocumentSync } from "@office-open/docx";
const buffer = generateDocumentSync({
sections: [
{
children: [
{ paragraph: { heading: "Heading1", children: ["Document Title"] } },
{ paragraph: { children: [{ text: "Body text", italic: true }] } },
{
table: {
rows: [
{ cells: [{ children: [{ paragraph: "A1" }] }, { children: [{ paragraph: "B1" }] }] },
{ cells: [{ children: [{ paragraph: "A2" }] }, { children: [{ paragraph: "B2" }] }] },
],
},
},
],
},
],
});- OOXML Compliance: Strict adherence to the ISO/IEC 29500 OOXML specification
- Type Safety: Full TypeScript support with comprehensive types and autocomplete
- Pure JSON API: Define documents as plain data objects — zero class instantiation, ideal for AI agents
- Performance First: Pure string concatenation for XML generation, native zlib compression, no intermediate AST
- Modular Design: Shared core infrastructure across DOCX, PPTX, and XLSX
- Cross-Platform: Works in Node.js and browsers. Export to Buffer, Blob, Base64, stream, or string
- Node.js 18.x or higher
- pnpm 9.x or higher (recommended package manager)
- Git for version control
-
Clone the repository:
git clone https://github.com/DemoMacro/office-open.git cd office-open -
Install dependencies:
pnpm install
-
Development mode:
pnpm dev
-
Build all packages:
pnpm build
-
Test locally:
# Run tests pnpm test
pnpm dev # Development mode with watch
pnpm build # Build all packages
pnpm test # Run tests
pnpm check # Lint & formatWe welcome contributions! Here's how to get started:
-
Fork the repository on GitHub
-
Clone your fork:
git clone https://github.com/YOUR_USERNAME/office-open.git cd office-open -
Add upstream remote:
git remote add upstream https://github.com/DemoMacro/office-open.git
-
Install dependencies:
pnpm install
-
Development mode:
pnpm dev
- Code: Follow our project standards
- Test:
pnpm build && pnpm test - Commit: Use conventional commits (
feat:,fix:,docs:,style:,refactor:,perf:,test:,build:,ci:,chore:,revert:) - Push: Push to your fork
- Submit: Create a Pull Request to upstream repository
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ by Demo Macro