PptxGenJS: Generate PowerPoint Presentations with JavaScript

PptxGenJS: Generate PowerPoint Presentations with JavaScript

Summary

PptxGenJS is a powerful JavaScript library that enables developers to programmatically create professional PowerPoint presentations. It supports various environments, including Node.js, React, and web browsers, offering a comprehensive set of features for designing custom slides, charts, tables, and more. This library simplifies the process of generating .pptx files without requiring a PowerPoint installation.

Repository Info

Updated on May 25, 2026
View on GitHub

Introduction

PptxGenJS is a robust JavaScript library that empowers developers to programmatically create professional PowerPoint presentations. Compatible with Node.js, React, Angular, Vite, Electron, and web browsers, this tool eliminates the need for a PowerPoint installation or license. With PptxGenJS, you can design custom slides, charts, images, tables, and templates, generating standards-compliant Open Office XML (OOXML) files that are compatible with Microsoft PowerPoint, Apple Keynote, LibreOffice Impress, and Google Slides. The library also offers full TypeScript support, ensuring an enhanced development experience with autocomplete and inline documentation.

Installation

To get started with PptxGenJS, choose your preferred installation method:

Quick Install (Node-based)

npm install pptxgenjs
yarn add pptxgenjs

CDN (Browser Usage)

Use the bundled or minified version via jsDelivr:

<script src="https://cdn.jsdelivr.net/gh/gitbrent/pptxgenjs/dist/pptxgen.bundle.js"></script>

Examples

Creating presentations with PptxGenJS is a straightforward four-step process.

Angular/React, ES6, TypeScript

import pptxgen from "pptxgenjs";

// 1. Create a new Presentation
let pres = new pptxgen();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

Script/Web Browser

// 1. Create a new Presentation
let pres = new PptxGenJS();

// 2. Add a Slide
let slide = pres.addSlide();

// 3. Add one or more objects (Tables, Shapes, Images, Text and Media) to the Slide
let textboxText = "Hello World from PptxGenJS!";
let textboxOpts = { x: 1, y: 1, color: "363636" };
slide.addText(textboxText, textboxOpts);

// 4. Save the Presentation
pres.writeFile();

HTML to PowerPoint Magic

One of the most powerful features is the ability to convert any HTML <table> into fully formatted PowerPoint slides with a single line of code:

let pptx = new pptxgen();
pptx.tableToSlides("tableElementId");
pptx.writeFile({ fileName: "html2pptx-demo.pptx" });

Why Use PptxGenJS

PptxGenJS stands out for its versatility and comprehensive feature set:

  • Works Everywhere: Supports all major modern browsers, Node.js, React, Angular, Vite, Electron, and even serverless functions.
  • Full-Featured: Create all major slide objects, including text, tables, shapes, images, charts, and more. Define custom Slide Masters for consistent branding and support SVGs, animated GIFs, YouTube embeds, RTL text, and Asian fonts.
  • Simple & Powerful: Ridiculously easy to use, allowing you to create a presentation in just a few lines of code. It includes full TypeScript definitions for autocomplete and inline documentation, plus over 75 demo slides.
  • Flexible Export: Instantly download .pptx files from the browser or export as base64, Blob, Buffer, or Node stream.
  • HTML to PowerPoint Conversion: Effortlessly transform dynamic HTML tables, data reports, and tabular content into PowerPoint slides.

Links

Explore more about PptxGenJS through the following resources: