@office-open/pptx
Generate and parse .pptx presentations with a declarative TypeScript API. Works in Node.js and browsers.
Features
- 🖥️ Slide Management — Create presentations with multiple slides, slide masters, and slide layouts
- 🔷 Shapes — Rectangles, ellipses, lines, connectors, and custom geometry shapes
- ✍️ Text & Rich Formatting — Paragraphs, runs, fonts, colors, alignment, and spacing
- 📊 Tables — Full table support with rows, cells, borders, and cell properties
- 📈 Charts — Bar, line, pie, area, and scatter charts with customization
- 🧩 SmartArt — Built-in SmartArt graphic generation with multiple layouts and styles
- 🖼️ Images — Inline pictures with fills, transformations, and effects
- 🎨 Backgrounds — Solid color, gradient, and picture backgrounds
- 🔄 Transitions — Slide transitions with various types and durations
- ✨ Animations — Entrance, emphasis, exit, and motion path animations
- 🎬 Media — Video and audio embedding
- 🔗 Hyperlinks — Clickable hyperlinks on shapes and text
- 📑 Headers & Footers — Slide header/footer with date, slide number
- 📝 Notes — Speaker notes for each slide
- 👥 Group Shapes — Group multiple shapes together
- 🖌️ DrawingML — Shapes with fills, outlines, shadows, glow, reflection, and 3D effects
- 📖 Parsing — Parse existing .pptx files with
parsePresentation for round-trip workflows
- 🔧 Template Patching — Patch existing PPTX templates via placeholder replacement
Installation
pnpm add @office-open/pptx
npm install @office-open/pptx
yarn add @office-open/pptx
bun add @office-open/pptx
Quick Start
import { generatePresentation } from "@office-open/pptx";
import { writeFileSync } from "node:fs";
const buffer = await generatePresentation({
slides: [
{
children: [
{
shape: {
textBody: {
children: [{ paragraph: { children: ["Hello World"] } }],
},
fill: "4472C4",
x: 100,
y: 100,
width: 600,
height: 400,
},
},
],
},
],
});
writeFileSync("presentation.pptx", buffer);
Parsing
Read existing .pptx files and re-create them as PresentationOptions:
import { parsePresentation, generatePresentation } from "@office-open/pptx";
import { readFileSync, writeFileSync } from "node:fs";
const opts = parsePresentation(new Uint8Array(readFileSync("input.pptx")));
const buffer = await generatePresentation(opts);
writeFileSync("output.pptx", buffer);
Benchmark
Performance vs PptxGenJS (higher ops/s is better, Windows 11 / Node 24).
Default = XML DEFLATE level 1 (SuperFast); media is split by type, matching MS Office PowerPoint — already-compressed formats (PNG/JPEG/GIF) are STOREd, the rest (EMF/WMF/BMP/TIFF/…) use DEFLATE level 1 (verified on a real MS Office file). All STORE = no compression ({ compression: { xml: 0, media: 0 } }). PptxGenJS (async only) defaults to STORE (via JSZip), supports DEFLATE via compression: true (applies to ALL entries including images).
await generatePresentation(options);
await generatePresentation(options, { compression: { xml: 0, media: 0 } });
Create + toBuffer (end-to-end)
| Simple (2 shapes) | 1,684 ops/s | 773 ops/s | 6,061 ops/s | 5,249 ops/s | 181 ops/s | 185 ops/s |
| Styled shapes (20) | 1,497 ops/s | 745 ops/s | 5,154 ops/s | 4,958 ops/s | 168 ops/s | 170 ops/s |
| Table (10x5) | 1,657 ops/s | 729 ops/s | 7,252 ops/s | 6,797 ops/s | 889 ops/s | 999 ops/s |
| Full featured | 1,635 ops/s | 714 ops/s | 4,816 ops/s | 4,321 ops/s | 96 ops/s | 94 ops/s |
Large Files — Create + toBuffer
| 30 slides x 20 shapes | 253 ops/s | 139 ops/s | 500 ops/s | 490 ops/s | 119 ops/s | 123 ops/s |
| 30 slides x 10 images | 320 ops/s | 160 ops/s | 793 ops/s | 795 ops/s | 0.26 ops/s | 0.30 ops/s |
| 100x10 table | 641 ops/s | 460 ops/s | 954 ops/s | 891 ops/s | 120 ops/s | 126 ops/s |
| 50 slides full | 169 ops/s | 87 ops/s | 326 ops/s | 317 ops/s | 0.90 ops/s | 0.90 ops/s |
Large File (~100MB) — Mixed Content
40 slides x (2 shapes + 2 mixed-size images + 3x3 table).
| 40 slides mixed | 227 ops/s | 124 ops/s | 708 ops/s | 721 ops/s | 0.23 ops/s | 0.22 ops/s |
Examples
Check the demo folder for working examples covering every feature.
License