Generate Office Open XML documents.
Create .docx, .pptx, and .xlsx files from plain JSON or fully typed TypeScript, and read legacy Office, RTF, and ODF inputs — a natural fit for AI agents and hand-written code 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 & TypeScript
Define documents as plain data — zero classes, zero boilerplate — with frozen JSON Schemas for tool-calling.
Rich Content
Paragraphs, tables, charts, images, SmartArt, math equations, headers, footers, and more.
Type-safe
Comprehensive TypeScript definitions power autocomplete and catch errors as you type.
Cross-platform
Runs in Node.js, browsers, Deno, and Bun; export to Buffer, Blob, Base64, stream, or string.
OOXML Core Complete
Every element and attribute in the 17 core OOXML Transitional schemas, both generating and parsing — newer Word extensions are tracked separately.
Modular Packages
Install just the format you need — including legacy readers and ODF — or the unified package with CLI and AI SDK tools on top.
Build documents with JSON or TypeScript
Define documents as plain JSON objects, or reach for the TypeScript API for a full IDE experience. Both produce the same valid OOXML markup.
{
"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": { "paragraphs": [{ "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, or patch templates by replacing {{placeholder}} tokens with new content.
import { parseDocument, patchDocument } from "@office-open/docx";
// Parse existing file
const opts = await parseDocument(buffer);
// opts.sections — document sections
// opts.title, opts.creator — core properties
// Patch template placeholders
const result = await patchDocument({
outputType: "uint8array",
data: buffer,
placeholders: {
name: { type: "paragraph", children: [{ text: "John" }] },
},
});
import { parsePresentation, patchPresentation } from "@office-open/pptx";
// Parse existing file
const opts = await parsePresentation(buffer);
// opts.slides — slide array
// opts.size, opts.title — presentation properties
// Patch template placeholders
const result = await patchPresentation({
outputType: "uint8array",
data: buffer,
placeholders: {
title: [{ text: "Updated", bold: true }],
},
});
import { parseWorkbook, patchWorkbook } from "@office-open/xlsx";
// Parse existing file
const opts = await parseWorkbook(buffer);
// opts.worksheets — worksheet array
// opts.styles — style definitions
// Patch template placeholders
const result = await patchWorkbook({
outputType: "uint8array",
data: buffer,
placeholders: {
name: "John Doe",
},
});