DEV Community

Abdullah Khalid Mirza
Abdullah Khalid Mirza

Posted on

I built a CLI tool that turns AI-generated code into PowerPoint files instantly

The Problem
Everyone uses PowerPoint. Nobody enjoys making it.

You spend hours picking fonts, aligning boxes, choosing colors. Or you pay a designer. Or you use a template that looks like everyone else's template.

Then AI came along. And I thought — wait. AI can write code. pptxgenjs can generate .pptx files from code. What if I connect the two?

The Idea
Here is the full flow:

  1. You ask ChatGPT, Claude, or Gemini to write a pptxgenjs script
  2. AI writes the code in seconds
  3. You save it as a .js file
  4. You run one terminal command
  5. A real .pptx file appears in your folder

That's it. No PowerPoint open. No dragging boxes. No design skills needed.

What I Built
I packaged this into an open source NPM CLI tool called pptx-builder.

npx pptx-builder my_presentation.js
Enter fullscreen mode Exit fullscreen mode

Anyone with Node.js installed can use it. No other setup. No install step. Just npx and go.

How To Use It

Step 1 — Ask AI
Open any AI tool. Use this exact prompt:

You are a PowerPoint presentation code generator using the pptxgenjs library.
Generate a complete Node.js script using pptxgenjs that creates a professional
PowerPoint presentation about [YOUR TOPIC HERE].
Rules:

  • Use only 6-digit hex colors (e.g. FF0000). No 8-digit, no transparency.
  • Do NOT use pptxgen.ShapeType — use plain strings like "rect" instead.
  • All content inside one single file, no imports except pptxgenjs.
  • Last line must be: pptx.writeFile({ fileName: "output.pptx" });
  • Do not wrap in markdown or backticks, return raw JS only. Make it visually beautiful with dark background, colors, and good layout. Include at least 8 slides.

Replace [YOUR TOPIC HERE] with anything. Business pitch. School project. Product launch. Company report.

Step 2 — Save the code
AI returns a JavaScript file. Copy it. Save as presentation.js.

Step 3 — Run

npx pptx-builder presentation.js
Enter fullscreen mode Exit fullscreen mode

First time it downloads the package automatically. Takes about 5 seconds.

Step 4 — Done
output.pptx is in your folder. Open it in PowerPoint or upload to Google Slides.

Why Not Just Use pptxgenjs Directly?
Great question. You can. But:

  • You need to install pptxgenjs in every project
  • You need to know how Node modules work
  • AI often generates code with errors (8-digit colors, ShapeType issues)
  • There is no standard prompt to give AI

pptx-builder solves all of this:

  • Zero install for end user
  • Works from any folder
  • Includes battle-tested AI prompt that avoids common errors
  • One command interface

The Rules That Matter
When asking AI to write pptxgenjs code, these rules prevent 90% of errors:
Rule 1 — 6-digit hex colors only
pptxgenjs does not support 8-digit hex (with transparency like FF000066). Always use standard 6-digit hex like FF0000.
Rule 2 — No ShapeType
AI often writes pptxgen.ShapeType.rect which crashes because pptxgen is an instance not a class. Use plain string "rect" instead.
Rule 3 — Single file
Keep everything in one .js file. No splitting into modules.
Rule 4 — writeFile as last line
Put pptx.writeFile() at the very end to ensure the file saves correctly.

Real Example Code
Here is what a working AI-generated file looks like:

const pptxgen = require("pptxgenjs");
const pptx = new pptxgen();

// Slide 1 - Title
let slide1 = pptx.addSlide();
slide1.background = { color: "0F0F1A" };
slide1.addText("Company Overview 2025", {
  x: 1, y: 1.5, w: 8, h: 1.2,
  fontSize: 48, bold: true,
  color: "7C83FD", align: "center"
});
slide1.addText("Presented by Abdullah Khalid Mirza", {
  x: 1, y: 3, w: 8, h: 0.7,
  fontSize: 18, color: "AAAAAA", align: "center"
});

// Slide 2 - Content
let slide2 = pptx.addSlide();
slide2.background = { color: "0D1B2A" };
slide2.addText("Key Points", {
  x: 0.5, y: 0.5, w: 9, h: 1,
  fontSize: 32, bold: true, color: "00C9A7"
});
slide2.addText("• Revenue grew 40% this year\n• 3 new markets entered\n• Team expanded to 50 people", {
  x: 0.8, y: 1.8, w: 8.5, h: 3,
  fontSize: 20, color: "DDDDDD"
});

pptx.writeFile({ fileName: "output.pptx" });
console.log("Done!");
Enter fullscreen mode Exit fullscreen mode

AI generates 8-10 slides like this in seconds. You run one command. Presentation ready.

Try It Now

npx pptx-builder your_file.js
Enter fullscreen mode Exit fullscreen mode

NPM page: npmjs.com/package/pptx-builder
GitHub: github.com/abdullahkhalidmirza/pptx-builder

What's Next

  • Template library with 10+ built-in themes
  • --out flag to specify output folder
  • Web UI so non-developers can use it too
  • Direct AI integration — describe your presentation, get the file

If you build something with it, share it. Would love to see what people create.

Abdullah Khalid Mirza

Top comments (0)