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.

Use Playwright when you need a PNG that reflects how a browser renders HTML. Install its Python package and browser binaries, load either a webpage URL or an HTML string, then save a screenshot with page.screenshot(). The same method can capture the viewport, a full scrollable page, or one selected element.

Install Playwright and its browser

Playwright runs a real browser, so setup includes both the Python package and browser binaries. In a terminal, run:

  1. python -m pip install playwright
  2. python -m playwright install chromium

The first command installs the Python package; the second downloads Chromium. The Playwright for Python getting-started guide also documents installing browser binaries with playwright install, and demonstrates Chromium, Firefox, and WebKit. Use the browser-install guidance for your operating system and runtime if you need a different browser or deployment setup.

The examples below use the synchronous API and Chromium. Playwright also offers an asynchronous API; its getting-started guide recommends that API for asyncio projects. Keep the API style consistent with the rest of your application.

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

Convert a webpage URL to a PNG

This complete script opens a page in headless Chromium, saves a viewport screenshot as output.png, and closes the browser even if navigation or capture raises an exception:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    try:
        page = browser.new_page()
        page.goto("https://example.com")
        page.screenshot(path="output.png")
    finally:
        browser.close()

Save it as html_to_png.py, then run python html_to_png.py. The file is written to the script’s current working directory. Replace the URL with the page you want to capture. The Page API documents navigation and screenshot methods; PNG is the default screenshot format, so a path ending in .png produces a PNG.

By default, the screenshot shows the current viewport, not necessarily the whole page. The browser’s default viewport is used unless you specify another one. For repeatable output, set the viewport explicitly when creating the page, for example:

page = browser.new_page(viewport={"width": 1440, "height": 1000})

Choose dimensions that suit the intended output. A different viewport can change responsive layouts, line breaks, and which content is visible.

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

Convert an HTML string directly

When your markup is already in Python, call page.set_content() instead of navigating to a URL:

from playwright.sync_api import sync_playwright

html = """<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
      body { font: 18px sans-serif; padding: 24px; }
      h1 { color: #174ea6; }
    </style>
  </head>
  <body>
    <h1>Hello from HTML</h1>
    <p>This page will be saved as a PNG.</p>
  </body>
</html>"""

with sync_playwright() as p:
    browser = p.chromium.launch()
    try:
        page = browser.new_page()
        page.set_content(html)
        page.screenshot(path="output.png")
    finally:
        browser.close()

page.set_content(html) assigns markup to the page before capture. If the HTML refers to external stylesheets, fonts, scripts, or images, those resources still need to be available to the browser; a markup string alone does not embed them. For self-contained output, include the required CSS and assets in the markup or otherwise make them accessible.

Choose what to capture

Capture the full scrollable page

Set full_page=True to capture the page beyond the visible viewport:

page.screenshot(path="full-page.png", full_page=True)

Playwright captures the whole scrollable page as though it fit in a very tall screen. Very long pages can create large images, so consider whether a full-page PNG is practical for your storage and downstream processing needs.

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

Capture a single element

Use a locator when you want a component, chart, card, or other selected part of the page rather than the entire viewport:

page.locator("#report").screenshot(path="report.png")

Replace #report with a CSS selector that matches the element. If the selector does not identify an element on the loaded page, the capture cannot target the intended content; confirm the selector against the page’s HTML.

Keep the PNG in memory

Omit the path to receive image bytes instead of writing directly to a file:

image_bytes = page.screenshot()
# Use image_bytes with your storage, response, or image-processing code.

The screenshot API returns bytes in this case. This is useful when another part of your program will upload, transform, or return the image without first saving it to disk.

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.

Make the background transparent

For supported screenshot output, use omit_background=True:

page.screenshot(path="transparent.png", omit_background=True)

This hides the default white background so the PNG can have transparency. The option does not apply to JPEG.

Wait for dynamic content before capture

A navigation call returning does not guarantee that every remote image, animation, or client-rendered component is ready. Choose a readiness condition that reflects the page you are capturing rather than relying on one fixed delay for every site.

For example, wait for a known element before taking a screenshot:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
page.goto("https://example.com/dashboard")
page.locator("#report-ready").wait_for()
page.screenshot(path="dashboard.png")

Replace #report-ready with an element that appears when the relevant content is available. If a page has no reliable marker, a delay may help for that particular page, but it is not a universal guarantee. Check the result when content depends on slow network requests or asynchronous rendering.

Or skip the browser setup

If you need a screenshot from a script without installing and managing browser binaries, ScreenshotNeo accepts a URL in one GET request and returns a screenshot. For example, this Python call writes the response body to a PNG file:

import requests

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

See the ScreenshotNeo API documentation for request options and response details. Cookie banners are accepted and removed along with more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.

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

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

Troubleshoot common problems

Playwright is installed, but Chromium will not launch

The Python package and browser binaries are separate setup components. Run python -m playwright install chromium in the same environment where the script runs. In managed or containerized environments, consult the official installation guidance for the relevant operating system and runtime.

The PNG is blank or misses content

Check that navigation reached the intended page and that the relevant content has rendered before capture. For client-rendered content, wait for a page-specific selector or state rather than assuming navigation alone is sufficient. If the image uses a full-page capture, confirm that the content is part of the page’s scrollable area.

Styles or images are missing from HTML supplied as a string

Inspect the markup for linked resources and verify that the browser can load them. Relative URLs may not resolve as intended when the page is set from a standalone string; use accessible absolute URLs or include the required assets in the markup.

The output is cropped

The default screenshot is the viewport. Use full_page=True for the full scrollable page, or select the exact element with locator(...).screenshot(). If the page layout itself is wrong, choose the viewport dimensions that trigger the desired responsive layout.

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

The script leaves browser processes running after an error

Put browser.close() in a finally block, as in the examples, so the browser is closed when an exception occurs. In a larger application, also keep browser and page lifetimes scoped to the work that uses them.

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

Performance, reliability, and cost considerations

Playwright is a local rendering workflow: your script launches a browser, loads the page, and writes or returns the image. You are responsible for having the package and browser binaries available in the runtime and for choosing capture timing appropriate to the page. Use a smaller viewport or an element capture when a full-page image is unnecessarily large. For automated workloads, ensure browser resources are closed reliably and avoid treating a single fixed sleep as proof that arbitrary dynamic content is ready.

The documentation establishes the capture methods and setup, not a universal runtime, rendering benchmark, or success guarantee across arbitrary sites. Page behavior depends on the HTML, assets, network conditions, and chosen readiness condition. ScreenshotNeo is a hosted alternative with plan-based monthly allowances; its charges apply to billable clean shots rather than the excluded outcomes described above.

When another renderer may fit

WeasyPrint is an HTML/CSS rendering library, but the inspected WeasyPrint API reference describes PDF output and stylesheet behavior; it does not establish a direct HTML-to-PNG workflow. Do not assume it is a drop-in replacement for a browser screenshot. Confirm that a renderer supports the precise CSS, JavaScript behavior, and output format your project requires. For pages that depend on browser-side JavaScript, Playwright’s browser-based capture is the documented method covered here.

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

Frequently Asked Questions

Can I convert a local HTML file to PNG with Playwright?

Yes. Load the file in a browser page, then call page.screenshot(path="output.png"); use an absolute file URL when navigating to it.

Can Playwright save a screenshot as PNG without extra format settings?

Yes. PNG is the documented default screenshot format; use a path ending in .png.

Does taking a screenshot execute page JavaScript?

The examples render content in a browser. Whether the content you need is ready still depends on the page; wait for an appropriate page-specific condition before capture.

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.

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