React · HTML to Image

Convert React Components to Image

Server-render any React component to HTML, then convert it to a pixel-perfect image with one API call. No canvas, no dom-to-image hacks — just clean output.

React / TypeScriptrenderpix API example
// utils/renderToImage.ts
import { renderToStaticMarkup } from "react-dom/server";
import { type ReactElement } from "react";

export async function componentToImage(
  element: ReactElement,
  opts: { width?: number; height?: number; format?: string } = {}
): Promise<Buffer> {
  const html = renderToStaticMarkup(element);
  const res = await fetch("https://renderpix.dev/v1/render", {
    method: "POST",
    headers: {
      "X-API-Key": process.env.RENDERPIX_API_KEY!,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      html,
      width:  opts.width  ?? 1200,
      height: opts.height ?? 630,
      format: opts.format ?? "png",
    }),
  });
  return Buffer.from(await res.arrayBuffer());
}

// Usage
const buf = await componentToImage(
  <OgCard title="Hello World" domain="mysite.com" />
);
fs.writeFileSync("og.png", buf);

Common use cases

🖼️
OG image generation
Render React OG card components to 1200x630 PNG images.
🏆
Award badges
Turn React badge components into shareable image assets.
📊
Chart exports
Export recharts or chart.js renders as static images.
💳
Social cards
Generate shareable profile or post cards from React templates.

Start converting HTML to images for free

100 free renders/month. No credit card. Set up in 2 minutes.

Get free API key