First published on the Accreditly blog.

You need a screenshot of a web page from a Node script: a thumbnail for a link, a visual record of a competitor's pricing page, an automated grab of a dashboard for a report. The instinct is to reach for Puppeteer, which means bundling a copy of Chromium, keeping it patched, and finding somewhere with enough memory to run it. For most jobs that is far more than you need. A screenshot API does the browser part for you, and your Node code shrinks to a single fetch. This article shows how to turn any URL into a PNG from Node, including full-page captures and grabbing one specific element.

One request instead of a browser

The whole task comes down to sending a URL to an endpoint and getting an image back. No puppeteer.launch, no --no-sandbox flags, no Chromium layer in your deploy. We use the HTML to Image API from plain Node, with the global fetch that ships in Node 18 and later.

async function screenshot(url, opts = {}) {