DEV Community

Cover image for I Built Web2Docx – A Simple API to Convert HTML to PDF, DOCX & Images
Rishu Kumar
Rishu Kumar

Posted on

I Built Web2Docx – A Simple API to Convert HTML to PDF, DOCX & Images

Hey Dev.to folks πŸ‘‹

I wanted to share something I recently launched β€” Web2Docx β€” a simple API that converts HTML (or any URL) into PDF, DOCX, and image files.

Why I Built This
I was working on a client project last year where I had to generate custom invoices, certificates, and a lot of user-facing documents. Every tool I tried felt like a headache β€” either too complex, too slow, or not flexible enough with styling.

Some options required setting up headless browsers, others involved Word macros or weird templating engines. I just wanted something fast and reliable β€” pass some HTML and get a nice, styled PDF or DOCX back.

So I decided to build it myself.

What Web2Docx Does
πŸ› οΈ It supports:

HTML to PDF

HTML to DOCX

HTML to Image (PNG/JPEG)

⚑ Key highlights:

Fast and clean output

Supports modern CSS (no inline styles needed)

No need to install anything

Works great with React, Next.js, Node, etc.

You just send a POST request with your HTML or URL β€” and you get a downloadable file.

What's Unique
It's not based on puppeteer or headless Chrome (so it's faster and lighter).

DOCX generation is fully CSS-supported β€” no janky formatting.

Built with devs in mind: clean SDK and clear docs.

Try It Out
I just launched it on Product Hunt today. If you want to support or try it out, here’s the link:

πŸ‘‰ https://www.producthunt.com/posts/web2docx

Would love your feedback β€” especially from other devs who’ve been frustrated with document generation tools.

Documentations: Web2docx Documentation

How to Integrate It (Quick Example πŸš€)
You can get started in just a couple lines using our official SDK:

npm i @web2docx/web2docx-sdk
Enter fullscreen mode Exit fullscreen mode
const { Web2DocxClient } = require("@web2docx/web2docx-sdk");

const client = new Web2DocxClient("YOUR_API_KEY");

const fs = require("fs");

async function htmlToPdfExample() {
  const html = "<h1>Hello World</h1>";
  const pdfBuffer = await client.htmlToPdf(html);

  fs.writeFileSync("output.pdf", pdfBuffer);
}

htmlToPdfExample();
Enter fullscreen mode Exit fullscreen mode

Thanks for reading ❀️

Top comments (0)