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

To convert multiple HTML pages to PNG, render each page in a browser and save a screenshot for it. Playwright’s page.screenshot() API handles the individual capture; a loop, file naming, concurrency, and retries turn that operation into a batch workflow. A PNG is the rendered page at a chosen size and state—not a picture generated from HTML source without a browser render. Playwright’s screenshot documentation describes the per-page capture API, not a dedicated bulk command or universal throughput limit.

Choose the right kind of capture

Before writing a batch script, decide what each PNG should contain. The choice affects image dimensions and whether the result represents the whole document or only what is initially visible.

  • Viewport: captures the visible browser area at the selected viewport dimensions. Use this for consistent previews or page thumbnails.
  • Full page: captures the full scrollable document. Use it when content below the fold belongs in the image.
  • One element: captures a selected page component, such as a chart or card, rather than the entire page.

Playwright documents full-page screenshots and element screenshots in its screenshot guide and Locator screenshot API.

Install Playwright and prepare your inputs

The example below uses Node.js with Playwright. It accepts local HTML file paths, converts them to file URLs, opens each in Chromium, and writes one PNG per input. Install Node.js first, then run these commands in a new project directory:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
  1. npm init -y
  2. npm install playwright
  3. npx playwright install chromium

Save the following as convert.mjs. Pass input files as command-line arguments. Outputs go into a png directory, with names based on each input file.

import { chromium } from 'playwright';
import { mkdir } from 'node:fs/promises';
import path from 'node:path';
import { pathToFileURL } from 'node:url';

const inputs = process.argv.slice(2);
if (inputs.length === 0) {
  console.error('Usage: node convert.mjs file1.html file2.html [...]');
  process.exit(1);
}

const outputDir = 'png';
await mkdir(outputDir, { recursive: true });
const browser = await chromium.launch();

try {
  for (const input of inputs) {
    const page = await browser.newPage({
      viewport: { width: 1440, height: 900 },
      deviceScaleFactor: 1
    });
    const output = path.join(outputDir, `${path.parse(input).name}.png`);

    try {
      await page.goto(pathToFileURL(path.resolve(input)).href, {
        waitUntil: 'load',
        timeout: 30000
      });
      await page.screenshot({
        path: output,
        type: 'png',
        fullPage: true,
        animations: 'disabled',
        scale: 'css'
      });
      console.log(`Saved ${output}`);
    } catch (error) {
      console.error(`Failed ${input}: ${error.message}`);
    } finally {
      await page.close();
    }
  }
} finally {
  await browser.close();
}

Run it with, for example, node convert.mjs ./html/page-a.html ./html/page-b.html. Each successful input produces a PNG in png/; failures are logged, and the remaining inputs continue. The example is intentionally sequential, so it is simple to operate and does not open an unbounded number of browser pages.

Adapt the batch for URLs or different outputs

Capture web pages instead of local files

For URLs, replace the file-URL conversion with the URL itself. A minimal input list and navigation pattern looks like this:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
const inputs = [
  'https://example.com/',
  'https://example.org/'
];

for (const url of inputs) {
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
  try {
    await page.goto(url, { waitUntil: 'load', timeout: 30000 });
    await page.screenshot({ path: `png/${new URL(url).hostname}.png`, fullPage: true });
  } finally {
    await page.close();
  }
}

For production batches, generate filenames from a stable input ID rather than just the hostname: multiple URLs on the same host otherwise overwrite one another. If the input list contains untrusted URLs, validate them and restrict access to internal or otherwise sensitive network locations before navigating.

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

Choose page readiness deliberately

waitUntil: 'load' waits for the page load event, but it does not guarantee that every asynchronous widget, image, or client-side render is finished. If a page has a known completion marker, wait for it before capturing:

await page.goto(url, { waitUntil: 'domcontentloaded', timeout: 30000 });
await page.locator('#report-ready').waitFor({ state: 'visible', timeout: 15000 });
await page.screenshot({ path: output, fullPage: true });

Replace #report-ready with a selector that genuinely indicates the desired content is ready. For pages without such a marker, a short delay may help with delayed rendering, but it is less reliable than waiting for a specific state.

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Capture an element, viewport, or full document

For an element, use a locator screenshot instead of the page screenshot:

await page.locator('.invoice').screenshot({ path: output, type: 'png' });

For viewport-only output, omit fullPage or set it to false. For the full scrollable page, set fullPage: true. See the screenshot guide for the documented capture modes.

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

Set scale, transparency, and visual state

Use scale: 'css' for one output pixel per CSS pixel. scale: 'device' follows the device pixel ratio and can create larger images. Set deviceScaleFactor on the browser context when you need a consistent device ratio. Transparency is available for PNG screenshots with omitBackground: true; it does not apply to JPEG. Playwright documents these screenshot options in its Page screenshot API.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

For repeatability, animations: 'disabled' can prevent animated content from appearing at arbitrary points in its cycle. The screenshot API also supports a style option for applying CSS during capture—for example, hiding a blinking cursor or an irrelevant dynamic element. Treat these as capture controls, not guarantees that different machines will render identical pixels: browser versions, operating systems, fonts, and page content can still change the result.

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

Make large batches reliable

The official screenshot API describes an operation on a page; it does not prescribe a batch scheduler, concurrency limit, retry policy, or throughput guarantee. Those are decisions for your workload. Add them deliberately rather than assuming that launching many pages at once will make a batch faster or safer.

  • Unique output paths: derive filenames from a stable ID or sanitized path and avoid collisions.
  • Bounded concurrency: process a small, controlled number of pages at once if sequential execution is too slow. Monitor memory and CPU, especially for full-page captures.
  • Retries: retry transient navigation or network failures a limited number of times; log each attempt and keep permanent errors visible.
  • Per-input results: record the source, output path, status, and error so a failed item can be rerun without repeating successful work.
  • Resource cleanup: close each page and the browser in cleanup paths, including when an input fails.
  • Stable environment: keep browser version, fonts, viewport, scale, and relevant CSS consistent when comparing images across runs.

Full-page screenshots can be much taller and larger in memory than viewport captures. If only a component or the visible region is needed, capturing that smaller area reduces output size and avoids unnecessary image processing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Troubleshoot common failures

  • The script says “Usage” and exits: no input paths were passed. Supply at least one HTML file after node convert.mjs.
  • Navigation reports a timeout: the page may be slow, waiting on resources, or unreachable. Check the path or URL, set an appropriate timeout for the workload, and choose a readiness condition that matches the page rather than waiting indefinitely.
  • The screenshot is blank or incomplete: confirm the page loaded the intended file and that client-rendered content had time to appear. Wait for a meaningful selector when possible; check whether the content is below the fold and use fullPage: true if needed.
  • Images are missing: a local HTML file may reference assets with paths that do not resolve from that file’s location, or a remote resource may fail to load. Verify asset paths and network access before changing screenshot timing.
  • PNG outputs overwrite each other: filenames are colliding. Include a stable unique identifier or sanitized relative path in each output name.
  • The result differs between runs or machines: dynamic content, animation, fonts, browser or host differences can alter rendering. Fix the environment and page state where possible, and use screenshot animation/style options to suppress known variability.
  • Memory use rises during a large job: reduce concurrency, close pages promptly, and avoid full-page capture when it is not required.

Or skip the browser setup

If your inputs are public web URLs and you would rather not install and manage a browser, ScreenshotNeo can return a screenshot from one GET request. Its API accepts the target URL and can return PNG, JPEG, WebP, or PDF; 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://stripe.com -o shot.webp

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. It also has an MCP server with screenshot tools for AI agents. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. It is a hosted URL capture service, so use the local Playwright workflow when you need to render local HTML files or require direct browser control. Learn about ScreenshotNeo, or sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Can I batch-convert HTML files without uploading them?

Yes. The Playwright example opens local HTML file paths in a local browser and writes PNG files to disk.

Does converting HTML to PNG preserve the HTML or make it editable?

No. The PNG is a raster image of the browser-rendered page; it does not preserve the source markup as editable content.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Can the batch script use Firefox or WebKit instead of Chromium?

Playwright supports multiple browser engines, but this example installs and launches Chromium. Install the desired engine and change the launch call if your project requires another 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.