How to Capture Website Screenshots with Node.js in 2026
January 31, 2026 • 5 min read
Taking screenshots of websites programmatically is a common need for developers. Whether you're building link previews, generating thumbnails, or creating visual testing tools, you need a reliable way to capture web pages.
Method 1: Puppeteer (Self-hosted)
const puppeteer = require('puppeteer');
async function takeScreenshot(url) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
await page.screenshot({ path: 'screenshot.png' });
await browser.close();
}
Cons: Chrome updates break code, memory issues, requires infrastructure.
Method 2: Screenshot API (Recommended)
curl "https://api.snapapi.pics/v1/screenshot?url=example.com" \
-H "X-API-Key: your_key" \
--output screenshot.png
Pros: No infrastructure, automatic scaling, built-in features, free tier available.
Try SnapAPI Free
Get 100 free screenshots per month. No credit card required.
Get Started Free →