Getting Started
Installation
How to install office-open packages
Package Manager
Install the package for the document type you need:
# pnpm
pnpm add @office-open/docx
pnpm add @office-open/pptx
# npm
npm install @office-open/docx
npm install @office-open/pptx
# yarn
yarn add @office-open/docx
yarn add @office-open/pptx
There is no single office-open package — install only the specific package(s) you need. Shared dependencies (@office-open/core, @office-open/xml) are pulled in automatically.
Browser
For browser usage, import directly from a CDN that supports ESM:
<script type="module">
import { Document, Packer, Paragraph, TextRun } from "https://esm.sh/@office-open/docx";
// ... create and export your document
</script>
Or use a bundler (Vite, Webpack, etc.) — the packages ship as standard ESM modules and work out of the box.
TypeScript
All packages are written in TypeScript and ship with built-in type definitions. No additional @types packages are needed.
import { Document, Packer, Paragraph, TextRun } from "@office-open/docx";
// Full type support and autocomplete
const doc = new Document({
sections: [
{
children: [
new Paragraph({
children: [new TextRun({ text: "Hello, World!", bold: true })],
}),
],
},
],
});
Requirements
- Node.js >= 18
- TypeScript >= 5.0 (optional, but recommended)