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

To convert an HTML URL to a PNG, render the URL in a real browser and save the rendered page as a screenshot. Changing .html to .png does not perform a conversion: HTML must be laid out with CSS, fonts, images, JavaScript, and viewport settings before an image can represent it.

This guide shows reproducible Puppeteer and Playwright workflows, explains viewport and full-page capture, covers readiness and resolution settings, and provides a hosted alternative when you do not want to manage a browser.

What URL-to-PNG conversion actually does

A URL points to a document that a browser fetches and renders. A screenshot records the pixels produced under specific conditions: browser engine, viewport size, device scale, loaded resources, cookies, JavaScript state, and page readiness. The same URL can therefore produce different PNGs on different runs.

Use browser automation when you need control over those conditions, repeatable builds, element-level images, or access to the resulting image bytes. A hosted screenshot API is useful when you want to send a request without installing Chromium or maintaining browser workers.

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.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Choose the capture scope before writing code

Scope Use it when Typical setting
Viewport You need exactly what a visitor sees in the visible browser window. Default screenshot behavior
Full page Content below the fold belongs in one image, such as an article or landing page. fullPage: true
Element You need a chart, card, logo, or other component rather than the whole document. Locator or element screenshot

Full-page capture can produce a very tall PNG. For long pages, consider capturing sections or using a PDF instead. Element capture avoids unrelated navigation, ads, and surrounding whitespace.

Convert a URL with Puppeteer

Puppeteer is a JavaScript browser-automation library. Its documented workflow is to launch a browser, create a page, navigate, call page.screenshot(), and close the browser. PNG is the default screenshot type, and a file path ending in .png is a straightforward way to save the result.

Install and run

npm install puppeteer

Create url-to-png.js:

const puppeteer = require('puppeteer');

(async () => {
  const url = process.argv[2] || 'https://example.com';
  const browser = await puppeteer.launch({headless: true});
  try {
    const page = await browser.newPage();
    await page.setViewport({width: 1440, height: 900, deviceScaleFactor: 1});
    await page.goto(url, {waitUntil: 'networkidle2', timeout: 90000});
    await page.screenshot({path: 'screenshot.png', fullPage: true, type: 'png'});
    console.log('Saved screenshot.png');
  } finally {
    await browser.close();
  }
})();

Run it with:

node url-to-png.js https://example.com

The networkidle2 condition waits until there are no more than two active network connections for a short period. It is a useful starting point, not a universal rule. Analytics, chat, streaming, and polling can keep a page active indefinitely; in those cases use a different readiness strategy.

Wait for a known element or delay

await page.goto(url, {waitUntil: 'domcontentloaded', timeout: 90000});
await page.waitForSelector('#main-content', {timeout: 30000});
await new Promise(resolve => setTimeout(resolve, 1000));
await page.screenshot({path: 'screenshot.png', fullPage: true});

Waiting for a selector is usually more meaningful than an arbitrary delay when client-side rendering inserts the content you need. A short delay can still help fonts, transitions, or lazy images settle.

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.

Capture one element and control the background

const card = await page.$('.pricing-card');
if (!card) throw new Error('pricing card not found');
await card.screenshot({path: 'card.png', type: 'png'});

await page.screenshot({
  path: 'transparent.png',
  fullPage: true,
  omitBackground: true,
  type: 'png'
});

Convert a URL with Playwright

Playwright supports Chromium, Firefox, and WebKit. Choose the engine that matches your compatibility target; the same page can differ slightly between engines because font rendering and CSS support are not identical.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Install and run

npm install playwright
const { chromium } = require('playwright');

(async () => {
  const url = process.argv[2] || 'https://example.com';
  const browser = await chromium.launch();
  try {
    const context = await browser.newContext({
      viewport: {width: 1440, height: 900},
      deviceScaleFactor: 1
    });
    const page = await context.newPage();
    await page.goto(url, {waitUntil: 'networkidle', timeout: 90000});
    await page.screenshot({path: 'screenshot.png', fullPage: true, type: 'png'});
  } finally {
    await browser.close();
  }
})();

Playwright can return bytes instead of writing a file:

const pngBytes = await page.screenshot({type: 'png', fullPage: false});
require('node:fs').writeFileSync('screenshot.png', pngBytes);

Capture a locator

await page.locator('[data-testid="invoice"]').screenshot({path: 'invoice.png'});

Element screenshots wait for the locator to resolve and are preferable to manually calculating coordinates. If the element is outside the viewport, Playwright scrolls it into view before capture.

Set viewport, scale, and browser state deliberately

Viewport dimensions

Set width and height to the layout you want to test or publish. Responsive pages may show a mobile menu at 390 pixels and a desktop navigation at 1440 pixels. If you omit the viewport, the library’s default can make output vary between projects.

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

CSS pixels versus device pixels

A device scale factor or screenshot scale changes output resolution. A scale of one keeps one image pixel per CSS pixel; a higher device scale produces a larger, sharper file but consumes more memory and storage. Playwright documents a choice between CSS-pixel and device-pixel scaling. Keep the setting stable if you compare screenshots in tests.

Fonts, images, and lazy content

Wait for the content that matters. You can wait for a selector, use a controlled delay, or check that images have completed:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
await page.waitForFunction(() =>
  [...document.images].every(img => img.complete)
);

Some lazy-loaded images load only after scrolling. For a full-page shot, scroll gradually before the final wait:

await page.evaluate(async () => {
  await new Promise(resolve => {
    let y = 0;
    const step = 600;
    const timer = setInterval(() => {
      window.scrollBy(0, step);
      y += step;
      if (y >= document.body.scrollHeight) {
        clearInterval(timer);
        window.scrollTo(0, 0);
        resolve();
      }
    }, 100);
  });
});

Authentication and private pages

For a page requiring login, create a context with the required cookies or use an authenticated session. Do not hard-code credentials in source control. Redact secrets from logs and ensure the target is authorized for automated access.

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

Command-line and hosted options

If you already run Node.js, Puppeteer or Playwright gives the most control. A hosted API removes browser installation, patching, sandbox configuration, and worker management. ScreenshotNeo is the first service to try for URL screenshots: it produces clean shots, bills only clean captures, and its paid entry plan is $5 for 3,000 shots.

cURL

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

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
require('node:fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

See the ScreenshotNeo documentation for request parameters and response headers. The API supports PNG, JPEG, WebP, and PDF; the example above writes WebP because the response format is selected by the request or defaults. Set the image format according to your integration’s needs.

Or skip the browser setup

ScreenshotNeo accepts a URL and handles the rendering service for you. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and whether the request was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

Every plan includes the features: full-page and CSS-selector capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF controls, custom CSS and JavaScript, pre-capture clicks, waits, request blocking, headers, cookies, user agent, authorization, timezone, geolocation, transparent backgrounds, resizing, configurable caching, signed image links, asynchronous jobs with signed webhooks, bulk capture for 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work to ease migration.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Plan Allowance Price
Free 1,000 shots/month Free, no card
Starter 3,000 shots $5
Growth 15,000 shots $15
Pro 60,000 shots $39
Scale 250,000 shots $99
Business 1,000,000 shots $249

Yearly billing gives two months free. Sign up for ScreenshotNeo to get 1,000 screenshots a month free with no card.

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

Troubleshooting URL-to-PNG captures

The screenshot is blank

Check the URL, response status, redirects, and JavaScript console. Wait for the selector that contains the rendered content rather than only waiting for the initial HTML. A blocked cross-origin resource or bot challenge can also leave an otherwise successful navigation empty.

Images or fonts are missing

Wait for image completion, allow enough time for web fonts, and verify that the browser process can reach every asset host. Private assets require authenticated cookies or headers. Capture after lazy content has been triggered.

Navigation times out

Raise the timeout only when the page is legitimately slow. For pages with persistent requests, use domcontentloaded plus a selector wait instead of a network-idle condition. Record the failing URL and redirect chain so intermittent failures can be separated from deterministic blocks.

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

The output is cropped

Use fullPage: true for the entire scrollable document, or capture the specific locator. If a fixed header overlaps content, hide it with page CSS before capture or choose an element boundary that excludes it.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Text looks too small

Increase the viewport width or device scale, but remember that a larger scale increases PNG dimensions. Keep viewport and scale consistent across runs to avoid false visual differences.

Browser launch fails in CI

Install the browser binaries required by your library, use the supported Linux dependencies, and check sandbox restrictions in your CI environment. Reuse a browser process for multiple URLs, but always close pages and contexts so memory does not grow without bound.

Reliability, performance, and cost considerations

  • Launch one browser and reuse it for a batch of pages; launching a new process for every URL adds substantial overhead.
  • Set explicit navigation and selector timeouts, then capture errors with the URL and stage that failed.
  • Limit concurrency to what the host can render without exhausting CPU, memory, file descriptors, or network bandwidth.
  • Use PNG when lossless pixels or visual tests matter. JPEG or WebP can be smaller when your downstream system accepts them.
  • Cache deterministic pages when freshness is not required. Do not cache personalized or rapidly changing content under a shared key.
  • For visual regression, fix browser version, engine, viewport, scale, locale, timezone, fonts, and animation state. Otherwise harmless environmental changes can look like page changes.

Which method should you use?

  • Use Puppeteer when your JavaScript project needs Chromium automation and direct access to browser APIs.
  • Use Playwright when you need Chromium, Firefox, or WebKit coverage, locator screenshots, or returned image bytes.
  • Use ScreenshotNeo when you want a single HTTP request, cleanup of consent UI, usage-aware billing, MCP tools, or managed scaling.

Frequently Asked Questions

Can I convert a local HTML file to PNG?

Yes. Launch the browser with a file URL such as file:///absolute/path/page.html, or serve the directory over a local HTTP server. Relative assets and browser security rules can differ between the two approaches.

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

Why does the same URL produce different PNGs?

Rendered output depends on viewport, device scale, browser engine and version, fonts, cookies, time, network responses, JavaScript state, and readiness timing. Fix those inputs for reproducible images.

Is a screenshot the same as printing HTML?

No. A screenshot records rendered pixels. Printing creates a paginated document and may apply print CSS, margins, headers, and page breaks; use PDF or print emulation when those are the goal.

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.