pptx-react-renderer is a browser-first library for parsing .pptx files and rendering them to semantic HTML.
The package is framework-agnostic, but it works naturally in React because the main API renders into a container element you control.
pptx-react-renderer is heavily under development.
It is already usable for browser-based slide previewing, but the renderer is not feature-complete and it does not aim to match PowerPoint perfectly yet. Expect rough edges, unsupported constructs, and rendering mismatches on complex decks.
- Parses
.pptxarchives client-side withjszip - Renders slides to regular DOM nodes and CSS
- Supports text, images, shapes, tables, and a subset of SmartArt/graphic frames
- Exposes both parse and render APIs
- Ships as ESM and CommonJS with TypeScript types
pnpm add pptx-react-rendererimport { renderPptx } from "pptx-react-renderer";
const response = await fetch("/deck.pptx");
const arrayBuffer = await response.arrayBuffer();
const container = document.getElementById("preview");
if (!container) {
throw new Error("Missing preview container");
}
await renderPptx(arrayBuffer, {
container,
scale: 0.6,
showSlideNumbers: true,
theme: "light",
});import { useEffect, useRef } from "react";
import { renderPptx } from "pptx-react-renderer";
export function PptxPreview({ file }: { file: ArrayBuffer | null }) {
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!file || !ref.current) return;
void renderPptx(file, {
container: ref.current,
scale: 0.7,
showSlideNumbers: true,
theme: "light",
});
}, [file]);
return <div ref={ref} />;
}This repo also includes a static browser playground under playground/ for drag-and-drop local .pptx rendering. It is designed for GitHub Pages publishing from the gh-pages branch and does not upload presentations to a server.
Parses a .pptx file and immediately renders the resulting slides into options.container.
input can be an ArrayBuffer or Uint8Array.
Returns a normalized slide model without rendering:
type PptxParseResult = {
slides: PptxSlide[];
slideWidth: number;
slideHeight: number;
title?: string;
};input can be an ArrayBuffer or Uint8Array.
Renders a previously parsed slide model into a container.
type RenderOptions = {
container: HTMLElement;
scale?: number;
showSlideNumbers?: boolean;
theme?: "light" | "dark";
};Defaults:
scale:1showSlideNumbers:truetheme:"light"
- text boxes with rich text runs and paragraph-level formatting
- images extracted from the PPTX archive and inlined as data URLs
- basic shapes and fills
- tables
- grouped slide content and a subset of graphic frames / SmartArt-like data
This is not a pixel-perfect PowerPoint clone. The goal is pragmatic HTML rendering of common slide content in browser applications.
- The package is browser-first. Parsing requires
DOMParser,FileReader, andBlob, and rendering requiresdocument. - Server-side rendering is not supported directly. Use the parser and renderer only in browser-like client runtimes.
- Grouped shapes are not fully reconstructed yet. In the current parser, group containers are simplified rather than expanded into their original child elements.
- Chart and table
graphicFramecontent is currently rendered as placeholder blocks instead of full chart/table fidelity. - SmartArt and diagram support is partial. The parser attempts to extract diagram data and drawing shapes, but many decks still fall back to simplified node/text rendering.
- Custom geometry support is incomplete. Some path data is handled, but arc commands are currently skipped.
- Missing or unresolved embedded images fall back to a placeholder image box.
- Theme support is intentionally minimal and limited to the library's light/dark wrapper styling.
- Large decks can use significant memory because image assets are converted to data URLs during parsing.
- Parsing requires browser APIs:
DOMParser,FileReader, andBlob. - Rendering additionally requires
document. - Server-side rendering is not supported directly.
- The published package currently targets Node.js 20+ for local development, testing, and build tooling.
- For React or Next.js apps, call the renderer from client-only code such as
useEffectin a client component. - If you run tests in Node, use a DOM-capable environment such as
jsdom. - Image data is currently inlined as data URLs during parsing, which can increase memory usage for large decks.
- ESM and CommonJS builds are published.
- TypeScript declarations are included.
- The package exports named exports only.
pnpm install
pnpm run fixtures:generate
pnpm run verify
pnpm run pack:check
pnpm run test:browser
pnpm run test:visualUse Node.js 20 or newer for local development. The current Vitest/Vite toolchain in this repo does not support Node 18.
To regenerate the committed sanitized golden fixture from a local source deck:
PPTX_COMPLEX_SOURCE="/absolute/path/to/source-deck.pptx" pnpm run fixtures:sanitize-complexThe sanitized fixture preserves slide structure, SmartArt/diagram XML, tables, groups, relationships, and media slots while replacing sensitive text, metadata, and image payloads.
- Follow semver.
- Merges to
mainare the release trigger. - Every pull request must carry exactly one release label:
release:patch,release:minor,release:major, orrelease:skip. - The
publishworkflow reads the merged PR label, resolves the next version, publishes to npm, and creates a matching GitHub release tag. - Before
1.0.0, release labels are intentionally softened:release:majorbecomes a semver minor bump, for example0.2.3 -> 0.3.0release:minorbecomes a semver patch bump, for example0.2.3 -> 0.2.4release:patchstays a patch bumprelease:skipsuppresses publication for that merge
- npm trusted publishing is configured for
OpenRenderKit/pptx-react-rendererand.github/workflows/publish.yml. - The package is currently published as
pptx-react-renderer@0.1.1. mainis intended to stay releasable; use branches and pull requests for normal changes.- Release tags matching
v*are protected against rewrites and deletions.
See docs/RELEASING.md for the concrete release flow and recovery steps.
- unit and parser/renderer regression tests run in
vitestwithjsdom - committed
.pptxfixtures undertest/fixtures/real/cover realistic parse and render paths - a Playwright smoke test renders a real fixture in Chromium against the built package
- a case-based visual-regression path renders real PPTX fixtures through LibreOffice, screenshots selected slides from the browser renderer, and diffs them with
pixelmatch - a sanitized golden deck derived from a complex local source presentation is committed so CI can exercise realistic SmartArt, tables, groups, and mixed media without depending on private files
- a committed
Slop-Sampledeck compares every slide in CI, including theme styling, placeholder text, notes-safe content, tables, images, and diagram-heavy layouts
pnpm run test:visual requires LibreOffice (soffice) and Poppler (pdftoppm) locally. CI runs the visual suite on every change and publishes metrics, diff images, and an HTML side-by-side report artifact, but it does not block routine 0.x or x.y.z work. On pull requests, CI also compares the current branch renderer output against the latest successful main visual artifact, posts a PR comment with ranked renderer changes plus regressed/improved fidelity sections, and publishes preview reports to GitHub Pages so the comment can link to stable browser-viewable outputs and embed top changed slide previews when there are non-zero deltas. Hard threshold enforcement remains available locally and for future major-release gates. See docs/TESTING.md for the visual-regression model, local prerequisites, and GitHub Actions behavior.
See CONTRIBUTING.md for local setup, verification, and release steps.
See SECURITY.md for vulnerability reporting guidance.