October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Cupertino desk6 min

How to Capture a Website Screenshot with Node.js on Mac

Use Puppeteer on macOS to open a website and save a viewport, full-page, or element screenshot with Node.js, with practical setup and troubleshooting guidance.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On macOS, the most direct way to capture a website screenshot with Node.js is Puppeteer: install it, launch its managed Chrome browser, navigate to a URL, and call page.screenshot(). The example below saves the visible viewport as a PNG and closes the browser even if navigation or capture fails.

Capture a website screenshot with Puppeteer

In a Terminal window, create a project, install Puppeteer, and save the following as screenshot.js. The full puppeteer package normally downloads a compatible Chrome for Testing build and chrome-headless-shell during installation.

As an Amazon Associate I earn from qualifying purchases.

npm init -y
npm install puppeteer

This script uses ES module syntax. Add "type": "module" to your project’s package.json if Node.js is treating .js files as CommonJS; alternatively, save the file as screenshot.mjs.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle2' });
  await page.screenshot({ path: 'screenshot.png' });
  console.log('Saved screenshot.png');
} finally {
  await browser.close();
}

Run it from the project directory with node screenshot.js. Puppeteer’s screenshot guide documents Page.screenshot(); the try/finally wrapper here ensures the browser is closed after success or failure. The file is written relative to the directory from which you run Node.

#1 Best Overall
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Blush
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Choose what to capture

Visible browser viewport

The example captures the page viewport. Set its dimensions before navigation if you need a particular desktop or mobile-sized layout:

await page.setViewport({ width: 1280, height: 800 });

Place this after newPage() and before goto(). Puppeteer’s Page API documents screenshot capture and page configuration in its Page API reference.

Full scrollable page

For a tall page rather than just the visible viewport, pass the full-page option:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.screenshot({ path: 'full-page.png', fullPage: true });

Full-page capture represents the scrollable page as a tall image. Very long pages may produce large image files, and pages that load content only as you scroll may require additional scrolling or site-specific waits before capture. See Puppeteer’s Screenshots guide for supported screenshot options.

Rank #2
Sale
Apple 2026 MacBook Air 13-inch Laptop with M5 chip: Built for AI, 13.6-inch Liquid Retina Display, 16GB Unified Memory, 512GB SSD, 12MP Center Stage Camera, Touch ID, Wi-Fi 7; Midnight
  • BUILT FOR COLLEGE. AND BEYOND — MacBook Air with the M5 chip packs blazing speed and powerful AI capabilities into an incredibly portable design. And with up to 18 hours of battery life,* this thin and light powerhouse is ready to take on almost any major, just about anywhere.
  • TEAR THROUGH TOUGH ASSIGNMENTS — With its faster CPU and unified memory, the M5 chip delivers even more performance and fluidity across apps, making multitasking and creative workflows smooth and responsive. A powerful Neural Engine and next-generation GPU with Neural Accelerators give you a powerful platform for AI.
  • MAKE QUICK WORK OF YOUR TO-DO LIST — Apple Intelligence helps you write, express yourself, and get things done effortlessly — whether it’s for school or everyday life. With groundbreaking privacy protections, it gives you peace of mind that no one else can access your data — not even Apple.*
  • UP TO 18 HOURS OF BATTERY LIFE — MacBook Air delivers incredible battery life with amazing performance, so you can power through a full day of classes without worrying about plugging in.
  • A BRILLIANT 13.6-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Air supports 1 billion colors, making photos and videos pop with rich contrast and sharp detail, and text appears supercrisp. So everything — from class presentations to movies to games — looks truly stunning.

One element

To capture a particular element, locate it and use the element handle’s screenshot method. This example waits for a CSS selector to appear:

const element = await page.waitForSelector('.product-card');
if (!element) throw new Error('Product card was not found');
await element.screenshot({ path: 'product-card.png' });

Replace .product-card with a selector on the target page. Puppeteer attempts to scroll a hidden element into view before capturing it. A selector that never appears causes the wait to time out; verify the selector and, if necessary, set an appropriate timeout in the wait options.

Image bytes instead of a file

If another part of your Node program needs the image data, capture without a path and retain the returned bytes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const imageBytes = await page.screenshot({ type: 'png' });

You can pass those bytes to an image-processing library or write them to a file with Node’s filesystem API. Puppeteer’s supported output options are documented in its Screenshots guide.

Rank #3
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Indigo
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

Wait for the page you actually need

waitUntil: 'networkidle2' waits for network activity to quiet according to Puppeteer’s navigation condition, but it is not proof that every visual element is ready. Analytics, polling, delayed widgets, lazy images, and client-side rendering can make readiness site-specific.

If a particular element signals that the useful content has loaded, wait for it explicitly after navigation:

await page.goto('https://example.com', { waitUntil: 'domcontentloaded' });
await page.waitForSelector('main article');
await page.screenshot({ path: 'article.png' });

Choose a selector that reflects the content you need. For pages that render fonts or images asynchronously, wait for the relevant content or resource before capture rather than assuming navigation completion guarantees a settled image.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Installing and configuring the browser on macOS

Puppeteer’s full package manages browser downloads in its cache by default. Its installation guide, version 25.12.0, gives an approximate macOS Chrome download size of 170 MB; this is version-sensitive and is not the total disk use for every project. See the current Puppeteer installation guide for installation behavior and configuration.

Rank #4
Apple 2026 MacBook Neo 13-inch Laptop with A18 Pro chip: Built for AI and Apple Intelligence, Liquid Retina Display, 8GB Unified Memory, 256GB SSD Storage, 1080p FaceTime HD Camera; Citrus
  • AN AMAZING MAC AT A SURPRISING PRICE — With an incredibly portable and durable aluminum design, up to 16 hours of battery life,* and the A18 Pro chip, MacBook Neo is ready to go wherever school takes you.
  • FOUR STUNNING COLORS. ONE DURABLE DESIGN — Choose from four beautiful colors — Silver, Blush, Citrus, or Indigo — each with a color-coordinated keyboard. And MacBook Neo is made with a durable recycled aluminum enclosure that helps it reach 60 percent recycled content by weight — the most ever in any Apple product.*
  • FLY THROUGH EVERYDAY ASSIGNMENTS — Whether you’re cramming for finals, using Apple Intelligence* to summarize class notes, creating presentations, or even playing the latest Apple Arcade game,* MacBook Neo delivers the performance and AI capabilities you need to get things done.
  • UP TO 16 HOURS OF BATTERY LIFE — MacBook Neo delivers all day battery life, so you can power through from early morning classes to late night study sessions without worrying about plugging in.
  • A VIBRANT 13-INCH DISPLAY* — The gorgeous Liquid Retina display on MacBook Neo supports 1 billion colors, so photos and videos pop and text is crisp for easy reading.

If Chrome was not downloaded

Some package managers and organizational policies block dependency install scripts. In that case, Puppeteer may install while skipping the browser download, and running the script can fail with a “Could not find Chrome” error. From the project directory, install Puppeteer’s browser explicitly:

npx puppeteer browsers install

When to use puppeteer-core

puppeteer-core does not download Chrome. Use it when you manage the browser yourself or connect to a remote browser, and configure the executable path or browser channel for the environment you are using. For a first local macOS setup, the standard puppeteer package avoids that extra browser-management step.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Is Playwright a better fit?

Playwright also provides a documented Node.js screenshot workflow. Its Page API shows capturing with WebKit and supports Chromium and Firefox as well. Choose based on the browser automation API and browser behavior your project needs, or whether the screenshots belong in a Playwright Test visual-comparison workflow; the available documentation does not establish that one library is universally faster or better on every Mac.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Playwright documents full-page capture and returning screenshots as a buffer in its Screenshots guide. Its Page API reference describes the page methods. For visual baselines, keep the capture environment consistent: Playwright notes that rendering can vary with host operating system, browser version, settings, hardware, power source, and headless mode.

Best Value
Sale
Apple 2026 MacBook Pro Laptop with Apple M5 Pro chip with 18-core CPU and 20-core GPU: Built for AI, 16.2-inch Liquid Retina XDR Display, 24GB Unified Memory, 1TB SSD, Wi-Fi 7; Space Black
  • FAST RUNS IN THE FAMILY — The 16-inch MacBook Pro with the M5 Pro or M5 Max chip brings next-generation speed and powerful on-device AI to personal, professional, and creative tasks. With all-day battery life, double the starting storage,* and a breathtaking Liquid Retina XDR display, it’s pro in every way.*
  • BUCKLE UP — Along with a next-generation CPU, faster unified memory, and up to 2x faster SSD storage,* M5 Pro and M5 Max feature a more powerful GPU with a Neural Accelerator built into each core, delivering faster AI performance and on-device training capabilities. So you can blaze through demanding workloads at mind-bending speeds.
  • BUILT FOR AI — Apple silicon, and every major component that powers it, is designed to run demanding on-device AI workloads like LLM inference and training. And Apple Intelligence helps you write, express yourself, and get things done effortlessly with groundbreaking privacy protections at every step.*
  • ALL-DAY BATTERY LIFE — MacBook Pro delivers the same exceptional performance whether it’s running on battery or plugged in.*
  • MACOS RUNS APPS FAST — All your go-to apps run lightning fast in macOS, including built-in apps like FaceTime and Messages. Plus, built-in virus protection and free software updates help keep your Mac running smoothly and securely.

Common problems and fixes

  • “Could not find Chrome.” The install script may have been blocked and browser binaries were not downloaded. Run npx puppeteer browsers install in the project.
  • import is rejected or reported as unexpected syntax. Node is interpreting the file as CommonJS. Add "type": "module" to package.json or use an .mjs filename.
  • The screenshot is blank or missing page content. Navigation may have completed before the target content rendered. Wait for a relevant selector or resource, and confirm the target page is accessible in the browser environment.
  • The element screenshot times out. Check that the CSS selector matches the current page and is not inside content that requires another interaction or wait.
  • The image is cut off at the viewport. Use fullPage: true for a full scrollable capture, or capture a specific element.
  • Visual-diff images change across machines. Keep operating system, browser version, settings, hardware, and headless mode consistent where possible. Review differences rather than treating every pixel change as an application defect.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request can return an image or PDF; this cURL example saves a WebP screenshot. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and other MCP clients. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

Can I save a screenshot as JPEG or WebP with Puppeteer?

Puppeteer supports screenshot output types including PNG, JPEG, and WebP where supported by its API and browser. Check the installed version’s screenshot guide for the relevant options.

Does Puppeteer require Google Chrome to be installed separately on a Mac?

The full puppeteer package normally downloads a compatible Chrome for Testing build and chrome-headless-shell. puppeteer-core does not download a browser, so you must provide or manage one.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.