Generate Office Open XML documents.
Create
.docx, .pptx, and .xlsx files with JSON or TypeScript. Designed for AI agents and traditional workflows alike.{
"sections": [
{
"children": [
{ "paragraph": { "children": [{ "text": "Hello, World!", "bold": true }] } }
]
}
]
}
pnpm add office-open
npm install office-open
yarn add office-open
bun add office-open
- JSON & TypeScriptCreate documents with pure JSON objects or the TypeScript functional API. The JSON-first design pairs naturally with AI agents, LLM workflows, and Zod-powered schemas.
- Rich ContentParagraphs, tables, images, charts, SmartArt, math equations, headers, footers, and more.
- Type-safeComprehensive TypeScript definitions for autocomplete and type safety across every API.
- Cross-platformRuns in Node.js, browsers, Deno, and Bun. Export to Buffer, Blob, Base64, stream, or string.
- OOXML CompliantOutput validates against the OOXML XSD and opens in Microsoft Office, WPS Office, LibreOffice, and Google Workspace.
- Modular PackagesInstall only what you need — docx, pptx, xlsx, xml, or core. The unified office-open package adds a CLI and AI SDK tools.
Build documents with JSON or TypeScript
Define documents as plain JSON objects — zero class instantiation — or use the TypeScript functional API for a full IDE experience. Both produce valid OOXML markup.
- Create Word documents with paragraphs, tables, images, and charts
- Create PowerPoint presentations with shapes, animations, and transitions
- Create Excel spreadsheets with styles, charts, and data validation
- High Performance with native zlib compression and streaming output
{
"sections": [
{
"children": [
{
"table": {
"rows": [
{ "cells": [{ "children": [{ "paragraph": "Name" }] }, { "children": [{ "paragraph": "Role" }] }] },
{ "cells": [{ "children": [{ "paragraph": "Alice" }] }, { "children": [{ "paragraph": "Engineer" }] }] },
{ "cells": [{ "children": [{ "paragraph": "Bob" }] }, { "children": [{ "paragraph": "Designer" }] }] }
]
}
}
]
}
]
}
{
"slides": [
{
"children": [
{
"shape": {
"x": 100, "y": 100, "width": 760, "height": 340,
"textBody": { "children": [{ "text": "Hello, World!", "size": 32 }] }
}
}
]
}
]
}
{
"worksheets": [
{
"name": "Sheet1",
"rows": [
{ "cells": [{ "value": "Name" }, { "value": "Score" }] },
{ "cells": [{ "value": "Alice" }, { "value": 95 }] },
{ "cells": [{ "value": "Bob" }, { "value": 88 }] }
]
}
]
}
Read and modify existing files
Parse
.docx, .pptx, and .xlsx files into structured objects for inspection, or patch templates by replacing {{placeholder}} tokens with new content.- Read document structure, styles, and content
- Patch template placeholders with new content
- Parse, modify, and re-export in a pipeline
import { parseDocument, patchDocument } from "@office-open/docx";
// Parse existing file
const opts = parseDocument(buffer);
// opts.sections — document sections
// opts.title, opts.creator — core properties
// Patch template placeholders
const result = await patchDocument({
outputType: "nodebuffer",
data: buffer,
placeholders: {
name: { type: "paragraph", children: [{ text: "John" }] },
},
});
import { parsePresentation, patchPresentation } from "@office-open/pptx";
// Parse existing file
const opts = parsePresentation(buffer);
// opts.slides — slide array
// opts.size, opts.title — presentation properties
// Patch template placeholders
const result = await patchPresentation({
outputType: "nodebuffer",
data: buffer,
placeholders: {
title: [{ text: "Updated", bold: true }],
},
});
import { parseWorkbook, patchWorkbook } from "@office-open/xlsx";
// Parse existing file
const opts = parseWorkbook(buffer);
// opts.worksheets — worksheet array
// opts.styles — style definitions
// Patch template placeholders
const result = await patchWorkbook({
outputType: "nodebuffer",
data: buffer,
placeholders: {
name: "John Doe",
},
});