PPTX

@office-open/pptx

Generate, parse, and patch .pptx presentations with a declarative TypeScript API

Installation

pnpm add @office-open/pptx

Quick Start

{
  "slides": [
    {
      "children": [
        {
          "shape": {
            "x": "1.3cm",
            "y": "1.3cm",
            "width": "20cm",
            "height": "3cm",
            "textBody": { "children": ["Hello World"] }
          }
        }
      ]
    }
  ]
}

Main Components

ComponentDescription
slides arrayRoot presentation — array of slides with properties
slideA single slide with shapes, media, and layout
shapeRectangle, rounded rectangle, and custom geometry shapes
groupGrouped shapes with collective transform
Text paragraphs and runsText paragraphs and runs inside shapes
table with rows and cellsTables with merged cells and styling
image / pictureEmbedded images on slides
chartBar, line, pie, area, and scatter charts
smartartPredefined SmartArt diagrams
video / audioEmbedded video and audio
line / connectorLines and connectors between elements
transitionSlide transition effects
animationShape entrance, emphasis, and exit animations
backgroundSlide background — solid, gradient, and picture fills
headers / footersSlide footers with date, number, and text
hyperlinkClickable hyperlinks on shapes and text
Slide masters and layoutsSlide masters and layouts for consistent design
notesSpeaker notes for each slide
themeColor schemes and font schemes
modifyVerifierPassword protection for presentation modification
photoAlbumPhoto album layout and frame settings
oleEmbedded OLE objects
lockedCanvasLocked canvas for non-editable drawing objects

Export Formats

Every async method has a synchronous counterpart (e.g., generatePresentationSync). See the page for the full list.

MethodReturnsUse Case
generatePresentation(opts)BufferNode.js file I/O
generatePresentation(opts, { type: "blob" })BlobBrowser downloads
generatePresentation(opts, { type: "base64" })stringData URLs, API payloads
generatePresentation(opts, { type: "string" })stringDebugging, inspection
generatePresentationStream(opts)ReadableStream<Uint8Array>Streaming large files

Patching

Modify existing .pptx templates by replacing {{placeholder}} tokens with new content:

import { patchPresentation } from "@office-open/pptx";

const result = await patchPresentation({
  outputType: "nodebuffer",
  data: templateBuffer,
  placeholders: {
    title: [{ text: "Updated", bold: true }],
  },
});

See for full documentation.

Parsing

Parse existing .pptx files into PresentationOptions for inspection or round-trip workflows:

import { parsePresentation } from "@office-open/pptx";

const opts = parsePresentation(buffer);
// opts.slides![0].children — shapes, tables, charts, etc.
// opts.slides![0].background — slide background
// opts.slides![0].transition — slide transition
// opts.slides![0].notes — speaker notes
// opts.title, opts.creator — core properties
// opts.size — slide size ("16:9", "4:3", or custom)

See for full documentation.

Slide Size

Use the size option to set slide dimensions. Accepts "16:9", "4:3", or a custom { width, height } object (in EMU or UniversalMeasure).

const buffer = await generatePresentation({
  size: "16:9",
  slides: [
    // ...
  ],
});
SizeDimensions
"16:9"13.33" × 7.5" (widescreen)
"4:3"10" × 7.5" (standard)
{ width, height }Custom size in EMU or UniversalMeasure
Copyright © 2026