DEV Community

Cover image for TIL a PowerPoint file is just a zip — so I converted .pptx to Word entirely in the browser
Bright Agbomado
Bright Agbomado

Posted on

TIL a PowerPoint file is just a zip — so I converted .pptx to Word entirely in the browser

Most file converters upload your files to a server. I wanted to see how far I could get without one. Turns out: all the way.
The trick is that Office files aren't really binary blobs — a .pptx is a zip archive full of XML. Rename it to .zip, unzip it, and you'll find each slide sitting there as its own XML file. Once you know that, "convert PowerPoint to Word in the browser" stops sounding impossible.
Three libraries chained together, all running client-side:

import JSZip from 'jszip';
import { Document, Packer, Paragraph } from 'docx';

// 1. Crack open the .pptx (it's a zip)
const zip = await JSZip.loadAsync(file);

// 2. Walk each slide's XML for text
const parser = new DOMParser();
const slideFiles = Object.keys(zip.files)
  .filter((n) => n.match(/ppt\/slides\/slide\d+\.xml$/));

const paragraphs = [];
for (const name of slideFiles) {
  const xml = await zip.files[name].async('string');
  const doc = parser.parseFromString(xml, 'application/xml');
  const texts = doc.getElementsByTagName('a:t'); // <a:t> holds the text runs
  for (const t of texts) {
    paragraphs.push(new Paragraph(t.textContent));
  }
}

// 3. Write it out as a .docx
const out = await Packer.toBlob(new Document({
  sections: [{ children: paragraphs }],
}));
Enter fullscreen mode Exit fullscreen mode

JSZip unzips, the browser's own DOMParser reads the slide XML ( tags are where the text lives), and docx writes the result to a .docx blob you can download. No server. No upload. No API key. The file never leaves your machine.

The nice side effect: because there's no upload cost, I let this one batch up to 25 files at once.

The honest tradeoff — pulling clean text and tables out of slide XML is the easy 80%; perfectly preserving every layout quirk is the hard 20%, and a pure-browser approach trades some of that fidelity for privacy and speed. For getting your slide content into an editable Word doc fast, it holds up well.

Live here if you want to try it: PowerPoint to word

Top comments (0)