Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

How to Bulk Screenshot URLs from a CSV File with Playwright

A practical Node.js workflow for parsing a CSV, validating URLs, and saving a Playwright screenshot for each row.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a Node.js script to parse the CSV, validate its URL column, then visit each address with Playwright and save a screenshot for that row. The example below runs sequentially by default, records individual failures without abandoning the batch, and lets you choose viewport or full-page captures.

Prepare the CSV and Node.js project

Use a header row with a clearly named URL column. For example, save this as urls.csv:

As an Amazon Associate I earn from qualifying purchases.

url
https://example.com
https://playwright.dev

Playwright’s documentation notes that its test runner runs in Node.js, so it can read local files and use a CSV library. Its parameterization guide demonstrates csv-parse/sync with headers and empty-line skipping: Playwright: Parameterize tests.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Create a project and install the browser automation and CSV dependencies:

#1 Best Overall
npm init -y
npm install playwright csv-parse
npx playwright install chromium

Save the script below as capture-csv.mjs. It uses Chromium; install another Playwright browser and change chromium if your targets need a different browser engine.

Run a CSV screenshot batch

This version validates the URL field, skips blank values, writes one image per valid row, and continues after a row-level error. Output names use row numbers rather than raw URLs, which can contain characters unsuitable for filenames.

import { readFile, mkdir } from 'node:fs/promises';
import { parse } from 'csv-parse/sync';
import { chromium } from 'playwright';

const inputPath = process.argv[2] ?? 'urls.csv';
const outputDir = process.argv[3] ?? 'screenshots';
const fullPage = process.env.FULL_PAGE === '1';
const imageType = process.env.IMAGE_TYPE ?? 'png'; // png, jpeg, or webp
const navigationTimeout = Number(process.env.NAVIGATION_TIMEOUT_MS ?? 30000);

if (!['png', 'jpeg', 'webp'].includes(imageType)) {
  throw new Error('IMAGE_TYPE must be png, jpeg, or webp');
}

const csv = await readFile(inputPath, 'utf8');
const rows = parse(csv, {
  columns: true,
  skip_empty_lines: true,
  trim: true,
});

if (rows.length && !Object.hasOwn(rows[0], 'url')) {
  throw new Error('CSV must include a header named "url"');
}

await mkdir(outputDir, { recursive: true });
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext({ viewport: { width: 1365, height: 768 } });

try {
  for (let index = 0; index < rows.length; index++) {
    const rowNumber = index + 2; // header occupies line 1 in this simple CSV
    const raw = rows[index].url?.trim();
    if (!raw) {
      console.warn(`Row ${rowNumber}: blank URL; skipped`);
      continue;
    }

    let target;
    try {
      target = new URL(raw);
      if (!['http:', 'https:'].includes(target.protocol)) {
        throw new Error('URL must use http or https');
      }
    } catch (error) {
      console.error(`Row ${rowNumber}: invalid URL ${JSON.stringify(raw)}: ${error.message}`);
      continue;
    }

    const page = await context.newPage();
    const filename = `${String(index + 1).padStart(5, '0')}.${imageType}`;
    const outputPath = `${outputDir}/${filename}`;

    try {
      await page.goto(target.href, {
        waitUntil: 'load',
        timeout: navigationTimeout,
      });
      // Replace or supplement the load wait with a target-specific readiness
      // condition when the page renders important content after load.
      await page.screenshot({
        path: outputPath,
        type: imageType,
        fullPage,
        scale: 'css',
      });
      console.log(`OK row ${rowNumber}: ${target.href} -> ${outputPath}`);
    } catch (error) {
      console.error(`FAIL row ${rowNumber}: ${target.href}: ${error.message}`);
    } finally {
      await page.close();
    }
  }
} finally {
  await context.close();
  await browser.close();
}

Run it from the project directory:

node capture-csv.mjs urls.csv screenshots

For full-page images, set the environment variable for the command:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
FULL_PAGE=1 node capture-csv.mjs urls.csv screenshots

The script uses load as its default navigation milestone, not as a guarantee that every dynamic interface is visually ready. If a target populates content after the initial load, add an explicit selector wait, a deliberate delay, or another condition suited to that site before taking the screenshot.

Choose capture size, format, and output handling

Viewport or full page

Without fullPage: true, Playwright captures the visible viewport. With it, Playwright captures the full scrollable page. Very tall or resource-heavy pages can take longer to capture and produce larger files; there is no fixed processing time or output size. See the Page API.

Rank #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Image format and scale

The API supports PNG, JPEG, and WebP screenshots. The script selects the format through IMAGE_TYPE and matches the file extension. PNG is the default. For JPEG or WebP, Playwright also supports a quality setting; add quality to the screenshot options if you want to trade image fidelity for smaller output. The API documents scale: 'css' as one image pixel per CSS pixel. scale: 'device' uses device pixels and can create larger images on high-DPI displays.

Row identity and duplicates

Each valid record gets a numbered filename based on its position in the parsed rows, so duplicate URLs still produce distinct files. The console output connects each filename to the URL. If you need a durable mapping after the run, write a separate manifest containing the row number, URL, filename, and result. This example skips blanks and reports malformed values rather than silently dropping them.

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

Scale the batch without hiding failures

The example processes one page at a time. That is straightforward to debug and avoids opening many pages at once. Playwright supports multiple pages in a browser context, but the documentation does not specify a universal concurrency value. Suitable parallelism depends on the pages, available machine resources, and each site’s behavior. If you add concurrency, make it configurable and keep per-row logging so one failure does not erase the status of other URLs. See Playwright: Pages.

For a large CSV, consider writing results incrementally to a log or manifest rather than keeping them only in terminal output. Set a navigation timeout appropriate to your targets; a timeout is a failed capture, not proof that the URL is invalid. Retry only when it fits your use case, and record retries and final outcomes rather than concealing intermittent errors.

For repeatable visual comparisons, keep the capture environment consistent. Playwright notes that screenshots can vary with operating system, browser version, settings, hardware, power source, and headless mode: Playwright: Visual comparisons.

Rank #3
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

  • “CSV must include a header named url”: Rename the column to exactly url, or change the script to use your actual header name.
  • Invalid URL or unsupported protocol: Check for missing schemes, stray whitespace, or values other than HTTP and HTTPS. The script trims whitespace but intentionally rejects other protocols.
  • Navigation timeout: The host may be slow, unreachable, or waiting on behavior beyond the selected load milestone. Confirm the URL works in a browser, adjust NAVIGATION_TIMEOUT_MS, and use a page-specific readiness condition where needed.
  • Screenshot contains a loading state or missing content: A successful page.goto() does not mean every application has finished rendering. Wait for a meaningful selector or other site-specific signal before capture.
  • Browser executable is missing: Install the browser used by the script with npx playwright install chromium.
  • Files are unexpectedly large: Full-page and device-scale screenshots can contain many more pixels. Try viewport capture or scale: 'css', and use JPEG or WebP with an appropriate quality setting when those formats suit the content.

Automation does not bypass access controls. A target may present authentication, bot checks, or other restrictions; follow the site’s rules and do not use this workflow to evade them.

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

When CSV-driven Playwright tests are a better fit

A direct script is suitable when the goal is simply to save a set of images. If each URL should be an independent test result in a test suite, Playwright’s parameterized-test approach can generate tests from CSV records; the official guide includes that pattern at Parameterize tests.

Or skip the browser setup

If you want a screenshot service to process URLs instead of maintaining a local browser script, ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. Its API accepts one GET request per URL and can return PNG, JPEG, WebP, or PDF. A one-call example using cURL:

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

See the ScreenshotNeo API documentation for authentication and request options. Before capture, it accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.

The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo’s free plan.

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

Frequently Asked Questions

Can Playwright save screenshots as WebP?

Yes. The Page API supports WebP; set the screenshot type to webp and use a matching filename extension.

Can I use the CSV rows as individual Playwright tests instead of running a capture script?

Yes. Playwright’s parameterization guide shows how to generate tests from CSV records, which is useful when each URL should have its own test result.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 2
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$285.00

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

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.