PowerPoint Object Model - A declarative TypeScript library for creating PowerPoint presentations
npm install @hirokisakabe/pompom (PowerPoint Object Model) is a library for declaratively describing PowerPoint presentations (pptx) in TypeScript. It is designed for use cases where JSON in POM format generated by AI is converted into PowerPoint files.
- Node.js 18 or higher (for Node.js environments)
- Modern browser with ES2020+ support (for browser environments)
> [!NOTE]
> pom works in both Node.js and browser environments. Text measurement uses opentype.js with bundled Noto Sans JP fonts, ensuring consistent layout across all environments.
``bash`
npm install @hirokisakabe/pom
`typescript
import { buildPptx, POMNode } from "@hirokisakabe/pom";
const slide: POMNode = {
type: "vstack",
w: "100%",
h: "max",
padding: 48,
gap: 24,
alignItems: "start",
children: [
{
type: "text",
text: "Presentation Title",
fontPx: 48,
bold: true,
},
{
type: "text",
text: "Subtitle",
fontPx: 24,
color: "666666",
},
],
};
const pptx = await buildPptx([slide], { w: 1280, h: 720 });
await pptx.writeFile({ fileName: "presentation.pptx" });
``
- Type-safe: Strict type definitions with TypeScript
- Declarative: Describe slides with JSON-like objects
- PowerPoint First: Native support for Shape features
- Flexible Layout: Automatic layout with VStack/HStack/Box
- Pixel Units: Intuitive pixel-based sizing (internally converted to inches)
- Master Slide: Automatically insert common headers, footers, and page numbers across all pages
- AI Friendly: Simple structure that makes it easy for LLMs to generate code
| Node | Description |
| ------------ | ---------------------------------------------- |
| text | Text with font styling and bullet points |
| image | Images from file path, URL, or base64 |
| table | Tables with customizable columns and rows |
| shape | PowerPoint shapes (roundRect, ellipse, etc.) |
| chart | Charts (bar, line, pie, area, doughnut, radar) |
| timeline | Timeline/roadmap visualizations |
| matrix | 2x2 positioning maps |
| tree | Organization charts and decision trees |
| flow | Flowcharts with nodes and edges |
| processArrow | Chevron-style process diagrams |
| box | Container for single child with padding |
| vstack | Vertical stack layout |
| hstack | Horizontal stack layout |
For detailed node documentation, see Nodes Reference.
| Document | Description |
| ----------------------------------------------- | --------------------------------------- |
| Nodes Reference | Complete reference for all node types |
| Master Slide | Headers, footers, and page numbers |
| Serverless Environments | Text measurement options for serverless |
| LLM Integration | Guide for generating slides with AI/LLM |
MIT