Skip to content
shbernalPublic

About

Create PowerPoint presentations from TypeScript

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

5,203 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A 28-line TypeScript program runs and writes report.pptx, a slide with a revenue bar chart

pptx-ts writes .pptx files from TypeScript. You describe slides in code, and a deck comes out that opens cleanly in desktop PowerPoint. PowerPoint never runs, so there is no Office licence and nothing to install on the machine doing the writing.

  • Text, tables that page across slides, shapes, connectors, pictures, SVG, video and audio.
  • Native charts backed by an embedded workbook, so PowerPoint's "Edit Data" works.
  • Slide masters, layouts, sections, speaker notes, gradients and an image clipped to a shape.
  • LaTeX maths, embedded spreadsheets and 3D models.
  • An HTML <table> becomes paged slides, in the browser or under Node.
  • Text measured against the real font, so a box shrinks or grows to fit before the file is written.
  • Opens existing decks too: inspect, edit, or turn one into code.

Nine slides from the two showcase decks: a consulting cover, a cost waterfall, a dark pitch-deck cover over a night sky, KPI cards, a pipeline diagram with connectors, a business-case table with Harvey balls, a terminal mock, a 2x2 prioritisation matrix and an area chart

pptx-ts wrote every slide above, and LibreOffice rendered them. They come from the two showcase decks.

Why pptx-ts?

Use it when a deck has to be built from data that changes:

  • a monthly report
  • one deck per customer
  • a hundred decks every night
  • a download button that hands the user a deck built from what they are looking at

Every deck has to open cleanly in desktop PowerPoint. Keynote, LibreOffice Impress and Google Slides import it on a best-effort basis.

Quickstart

  1. Install pptx-ts on your project:

    Node ≥ 24

    pnpm add pptx-ts
  2. Save this as hello.mts:

    import PptxTs from "pptx-ts"
    
    const pptx = new PptxTs()
    const slide = pptx.addSlide()
    
    slide.addText("Hello from pptx-ts", {
      x: 1,
      y: 1,
      w: 8,
      h: 1,
      fontSize: 24,
      color: "363636",
    })
    
    await pptx.writeFile({ fileName: "hello.pptx" })
  3. Run it. Node 24 strips the types itself, so there is no build step.

    node hello.mts
  4. Open hello.pptx.

Positions are in inches, from the top-left corner of a 10 by 5.625 inch slide. Your first deck builds a four-slide report from an array, with a table, a chart and speaker notes.

Read and edit decks too

PptxGenJS, the library pptx-ts descends from, only writes. pptx-ts also opens a .pptx you already have.

Entry point What it does
pptx-ts/inspect Slide count, size, parts, media and fonts, without loading the whole deck. Guide
pptx-ts/read Open a deck, change the text on slide four, save it. Parts you did not touch keep their original bytes. Guide
pptx-ts/script Print TypeScript that rebuilds a deck, plus a note for each construct it could not carry. Guide
import { readFile, writeFile } from "node:fs/promises"
import { Presentation } from "pptx-ts/read"

const deck = await Presentation.load(await readFile("report.pptx"))
const title = deck.slides[0]?.placeholder("title")
if (title) title.text = "Q3 review"

await writeFile("report.pptx", await deck.save())

The script printer is the quickest way to learn the API. Build a slide by hand in PowerPoint, then read the code for it.

How it works

pptx-ts writes a .pptx from your code; pptx-ts/read loads and saves it, pptx-ts/inspect lists its contents, and pptx-ts/script turns it back into TypeScript

A .pptx is a zip of XML parts. pptx-ts builds those parts from your calls and zips them, with no Office process involved.

Runtime Import writeFile
Node.js 24 or later import, or require() with the class on .default writes to disk
Browser, with a bundler import downloads the file
Browser, no build step import PptxTs from "https://esm.sh/pptx-ts/browser" downloads the file
Deno, Bun, edge workers import throws; use toBytes()

Where it runs lists every entry point.

How this compares with PptxGenJS

pptx-ts is an independent derivative of PptxGenJS, detached at its v4.0.1. Both were measured on 2026-10-11 by building the same 22 deck intents with each library and reading the bytes that came out.

  • Construct coverage: pptx-ts emitted 21 of 22, pptxgenjs 10 of 22. Nothing in the corpus is emitted by pptxgenjs and not by pptx-ts.
  • Schema validity: of the decks each library built, 21 of 21 pptx-ts decks and 0 of 10 pptxgenjs decks validate with no error against the Open XML SDK.
  • Adoption: pptxgenjs is downloaded 14,641,405 times a month, against 1,915 for pptx-ts. If a large installed base matters to you more than the differences above, use pptxgenjs.
  • Activity: last commit on the default branch, 2026-10-10 for pptx-ts and 2025-06-26 for pptxgenjs. Last npm publish, 2026-09-21 and 2025-06-26.

Where the two libraries part company is on the comparison page, and how it was measured has every full table. Every intent as each library expresses it, including the calls that differ, is on porting from PptxGenJS.

Learn more

Found a bug? Open an issue. Errors that are the library's fault print that link themselves.

If an agent writes most of your code, install the pptx-ts-upstream skill that ships in the package. It files a library defect the agent hits as an issue with a small reproduction, instead of a silent workaround. CONTRIBUTING.md has the install command.

About

Create PowerPoint presentations from TypeScript

Topics

Resources

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages