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

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

The most reliable way to convert a live webpage to an image in Python is to render it in a real browser with Playwright, then call page.screenshot(). Use full_page=True for the complete scrollable document, a locator screenshot for one element, or omit the file path to keep PNG/JPEG/WebP bytes in memory. For static HTML where browser JavaScript is unnecessary, WeasyPrint can be a useful alternative, provided its HTML/CSS support and security requirements fit your input.

Choose the renderer before writing code

Your choice depends on what “HTML” means in your project:

Requirement Best fit Reason
Live website, responsive layout, fonts, JavaScript, clicks or lazy loading Playwright It drives Chromium, Firefox or WebKit and captures the browser’s rendered page.
Entire scrollable page Playwright with full_page=True The screenshot extends beyond the current viewport.
One card, chart or other region Playwright locator screenshot The selector defines the capture boundary.
HTML string or document with mostly static CSS Playwright set_content() or WeasyPrint Both accept supplied markup; WeasyPrint also exposes a base_url for relative assets.

Playwright requires both the Python package and browser binaries. WeasyPrint is not established as a drop-in replacement for JavaScript-heavy browser pages, so test the exact document instead of assuming identical output. Its documentation also warns that untrusted HTML or CSS can create security risks.

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

Install Playwright and its browsers

  1. Create or activate a virtual environment.
  2. Install the package: pip install playwright.
  3. Download browser binaries: playwright install.

The package provides synchronous and asynchronous APIs. The examples below use the synchronous API because it is easiest to place in a script; the same operations are available asynchronously.

#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

Capture a webpage as a PNG

This complete script opens a URL, waits for the page navigation to finish, and writes a full-page PNG:

from playwright.sync_api import sync_playwright

url = "https://example.com"

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 900})
    page.goto(url, wait_until="networkidle")
    page.screenshot(path="page.png", full_page=True)
    browser.close()

Use a normal load or domcontentloaded wait when a site keeps analytics connections open and never reaches network idle. For pages that render content after navigation, wait for a stable selector or an explicit delay before capturing.

Capture only the viewport

page.screenshot(path="viewport.png")

Without full_page=True, the image is limited to the current viewport. Set the viewport when exact pixel dimensions matter.

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

Capture one element

card = page.locator("article.product-card").first
card.screenshot(path="card.png")

A locator screenshot is preferable to manually calculating clip coordinates because the element’s current rendered box determines the image.

Keep screenshot bytes in memory

image_bytes = page.screenshot(type="png")
with open("page.png", "wb") as output:
    output.write(image_bytes)

This is useful when you need to upload the result, hash it, or transform it without creating an intermediate file.

Choose PNG, JPEG or WebP

The Page API supports PNG, JPEG and WebP. PNG has no quality setting; JPEG and WebP accept a quality value. Use PNG for sharp text, transparency and lossless diagrams. Use JPEG for photographic pages when a smaller file matters. Use WebP when your downstream system accepts it and you want a modern compressed format.

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
page.screenshot(path="photo.jpg", type="jpeg", quality=85)
page.screenshot(path="page.webp", type="webp", quality=85)

Device scale also affects output size and sharpness. A retina-style capture can be requested when creating the page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page = browser.new_page(
    viewport={"width": 1280, "height": 800},
    device_scale_factor=2
)

Render supplied HTML instead of a URL

set_content() loads an HTML string into a browser page. Wait for the relevant element, font or image before taking the shot:

from playwright.sync_api import sync_playwright

html = """



Invoice

Ready to capture.

""" with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={"width": 1000, "height": 700}) page.set_content(html, wait_until="load") page.locator(".panel").wait_for(state="visible") page.screenshot(path="invoice.png", full_page=True) browser.close()

For relative images, stylesheets or fonts in supplied markup, provide usable URLs and confirm that the browser can reach them. A data URL or embedded CSS avoids dependence on a working local path.

Use WeasyPrint for static documents

WeasyPrint exposes a Python HTML API that accepts sources such as filenames, URLs and file objects. Its base_url tells the renderer how to resolve relative resources:

from weasyprint import HTML

HTML(
    string="""
    <html><body><h1>Report</h1><img src="images/logo.png"></body></html>
    """,
    base_url="/path/to/project"
).write_png("report.png")

Choose this route when the document’s supported HTML and CSS are sufficient and you do not need browser interaction. Do not assume JavaScript widgets, client-side data fetching or browser-only layout behavior will be reproduced. Treat user-supplied HTML and CSS as untrusted: isolate the rendering process, restrict accessible files and network resources, and validate content before rendering.

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

Make captures deterministic

Wait for the content you need

Prefer a meaningful readiness condition over an arbitrary long sleep:

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.
page.goto(url, wait_until="domcontentloaded")
page.locator("main.dashboard").wait_for(state="visible")
page.screenshot(path="dashboard.png", full_page=True)

If no selector represents readiness, a short page.wait_for_timeout(milliseconds) can handle a known animation, but it is less reliable than waiting for the actual result.

Control layout inputs

  • Set viewport width and height explicitly.
  • Set device_scale_factor when pixel density is part of the specification.
  • Select the browser engine that matches your compatibility target.
  • Freeze or disable animations with injected CSS when screenshots must be comparable.

Handle authentication and private pages

Use Playwright’s browser context facilities for cookies or an authenticated storage state, and never hard-code credentials in source control. If the page requires a login, capture only after an explicit post-login selector is visible.

Common failures and fixes

“Executable doesn’t exist” or browser launch errors

Install the browser binaries with playwright install. In containers, ensure the image includes the required browser dependencies and that the process has permission to launch the browser.

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.

The image is blank or missing late content

The screenshot probably ran before client-side rendering completed. Wait for a content selector, an image, or the application’s ready state. Check the URL and inspect console or network errors.

Relative images or CSS do not appear

For browser pages, verify the resource URL is reachable from the capture environment. For WeasyPrint, set base_url to the directory or URL that makes relative references resolvable.

The output is cropped

Use full_page=True for a complete scrollable page, or capture a locator whose box includes the intended content. For a fixed design, increase the viewport dimensions.

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

Network idle never arrives

Analytics, WebSockets and polling can keep connections open. Replace wait_until="networkidle" with domcontentloaded plus a selector wait.

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

Fonts or images differ between machines

Install the same fonts and browser version in each environment, or bundle assets. Keep viewport, scale factor, locale and timezone consistent.

WeasyPrint output differs from the browser

That is expected when the page depends on JavaScript or browser-specific behavior. Use Playwright for interactive pages, or simplify the document to the HTML/CSS features your WeasyPrint version supports.

Performance, reliability and cost considerations

Launching a browser for every image adds startup work. For batches, keep one browser process alive and create isolated contexts or pages per job, then close them deterministically. Limit concurrency to the memory available on the host. Reuse a page only when you can reliably clear cookies, storage and application state.

Set navigation and operation timeouts, record failures with the target URL and readiness condition, and retry transient network errors rather than deterministic selector failures. Store the exact viewport, browser engine, output type and application revision alongside each image so later differences are explainable. Screenshot dimensions and format directly affect file size; choose them from the consumer’s requirements instead of always requesting a full retina PNG.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API when you want one HTTP request instead of packaging a browser. It accepts a URL and returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie/consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status. It also offers an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools.

See the ScreenshotNeo API documentation for all options, including full-page and element capture, device presets, custom CSS and JavaScript, waits, request blocking, headers, cookies, user agents, authentication, timezone, geolocation, transparent backgrounds, resizing, cache TTLs, signed links, asynchronous webhooks, bulk capture and usage reporting.

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.

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('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

The free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account.

FAQ

Can Playwright return an image without writing a file?

Yes. Omit path and the screenshot method returns bytes that you can upload or process in memory.

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

Which format supports a quality parameter?

JPEG and WebP support quality controls; PNG does not.

Should I use synchronous or asynchronous Playwright?

Either API supports the same browser screenshot capabilities. Synchronous code is simpler for scripts; asynchronous code fits an existing async service.

Is WeasyPrint safe for arbitrary user HTML?

Its documentation warns that untrusted HTML or CSS can introduce security problems. Isolate and constrain untrusted rendering rather than treating it as safe by default.

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.

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.