Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsUse Playwright’s Python library to render HTML in a real browser and save the result with page.screenshot(path="output.png"). It works for HTML you supply directly as well as pages you open by URL, and it can capture the visible viewport, the whole page, or a specific element. If you would rather not install and run a browser yourself, a hosted screenshot API is another option.
Choose how to render the HTML
The key decision is where the browser runs. With Playwright, your Python process launches a browser and controls the page. That gives you direct control of the page and capture, but you are responsible for the browser runtime and its lifecycle. A hosted service renders remotely, which can avoid local browser setup but introduces an API credential, network dependency, and reliance on the provider’s service and terms.
| Approach | Input | Capture controls documented | Operational dependency |
|---|---|---|---|
| Playwright for Python | HTML loaded into a page, or a page opened by URL | Viewport, full page, element, image bytes, output format and related options | Python library and a browser installation; Playwright documents Chromium, Firefox, and WebKit |
| html2img hosted API | Supplied HTML or a publicly accessible URL, depending on endpoint | Width, height, full page, device pixel ratio, CSS injection, and waiting for a selector | Network access, API key, and the provider’s service |
The available documentation does not establish a measured winner for speed, cost, image fidelity, privacy, or reliability. Choose based on where you can run the browser, what input you have, and which operational responsibilities suit your project.
Render HTML locally with Playwright
Playwright’s screenshot guide documents a Python API that saves a browser capture to a file. This synchronous example renders markup provided by the script:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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.
from playwright.sync_api import sync_playwright
html = """
Hello from Python
This HTML was rendered in a browser.
"""
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page()
page.set_content(html)
page.screenshot(path="output.png")
browser.close()
The result is a PNG in the current working directory. The example uses Chromium; Playwright’s Python library also documents Firefox and WebKit, and provides both synchronous and asynchronous APIs. For current installation and browser setup steps, follow the official Playwright Python library guide; commands and system requirements can vary by environment.
Capture an existing page by URL
For a public site or a locally running web application, navigate the page before capturing it. This example waits for the page’s load event, but that event alone does not guarantee every site-specific asynchronous task or late-loading asset has finished.
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(viewport={"width": 1440, "height": 900})
page.goto("https://example.com", wait_until="load")
page.screenshot(path="page.png")
browser.close()
Use the URL of your own page in place of the example address. For a local app, start the app first and navigate to its local address. If the page relies on JavaScript, remote fonts, images, or other external resources, decide what “ready” means for that page before capturing. No single wait condition is a guarantee for every site; the screenshot documentation describes capture operations, not a universal readiness rule.
Choose what to capture
Visible viewport
A plain page.screenshot(...) captures the current viewport. Set the viewport when opening the page if the output needs a predictable layout. The rendered page may differ at different viewport sizes because responsive CSS can rearrange or hide content.
Rank #2
- 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.
Full scrollable page
Pass full_page=True to capture beyond the visible viewport:
page.screenshot(path="full-page.png", full_page=True)
This produces a tall image of the full scrollable page. On pages with lazy-loaded content, simply requesting a full-page screenshot may not trigger every asset or section to load as it would during a visitor’s scroll. Check the resulting image for missing content and use page-specific preparation where needed.
One element
When only a chart, card, or other region is needed, take a screenshot of a locator rather than the whole page:
page.locator(".report-card").screenshot(path="card.png")
Replace .report-card with a CSS selector matching the element you intend to capture. The locator must resolve to the intended element in the rendered page. If the selector matches nothing, or the element is not ready, the capture cannot produce the intended result.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Rank #3
- 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.
Image bytes instead of a file
The screenshot methods can return image bytes when no path is supplied. That is useful when you want to send the image to another service or process it without first writing a file:
image_bytes = page.screenshot()
# Pass image_bytes to your image-processing or upload code.
Use the returned bytes as binary image data; do not decode them as text. If a downstream step expects a particular format, set that format explicitly rather than relying on a filename extension.
Set the image format and appearance
The current Playwright Page API documentation describes PNG, JPEG, and WebP screenshot output. PNG is the documented default. A file path’s extension can determine the format when the format option is not supplied. JPEG’s documented default quality is 80; WebP quality 100 is lossless, while lower values are lossy. These API options are version-sensitive, so confirm them against the reference for the Playwright version installed in your project.
# JPEG with an explicit quality setting
page.screenshot(path="preview.jpg", type="jpeg", quality=85)
# WebP with an explicit quality setting
page.screenshot(path="preview.webp", type="webp", quality=90)
Quality applies to JPEG and WebP, not PNG. Choose a format based on the destination: PNG is a common choice for sharp text and graphics; JPEG and lossy WebP can reduce file size at the cost of image detail or artifacts.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #4
- 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
Scale, transparency, and masks
The Page API also documents scale controls for CSS-pixel or device-pixel output, an option for a transparent background, and screenshot masks. A higher device-pixel scale can create a larger raster image; the exact dimensions depend on the rendered page and selected capture scope. Transparency is useful when the page background should not be included. Masks can cover selected areas in a capture. Consult the Playwright Page API reference for the exact option names and behavior in your installed version.
Use a hosted renderer instead
If you prefer not to launch and manage a browser in the Python process, html2img documents a hosted API. Its getting-started documentation describes POST /api/html for supplied markup and a screenshot endpoint for valid, publicly reachable URLs. Requests require an API key. The documented controls include dimensions, full-page capture, device pixel ratio, CSS injection, and waiting for a selector; the service also identifies sync and async Python client APIs. See html2img’s getting-started documentation for its current request format and client details.
A hosted renderer can be useful when browser execution does not belong in your application environment. Before adopting one, assess how your HTML or URLs reach the service, how credentials are handled, and whether the provider’s current terms and operational requirements fit your use case. The available documentation does not establish that a hosted service is inherently cheaper, more private, faster, or more reliable than local rendering.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. Send one GET request with a URL to receive a PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie and consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and whether the request was billed.
For a public page, this cURL request saves a WebP image:
Best Value
- 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.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For the endpoint, authentication, and available parameters, see the ScreenshotNeo API documentation. Replace YOUR_API_KEY with your key and change the target URL as needed. ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
Troubleshoot common capture problems
- The browser does not launch: Confirm that Playwright and its browser installation are set up for your environment using the current library guide. The installed Python package alone may not mean the required browser runtime is ready.
- The output is blank or missing expected content: Check that navigation or
set_contentcompleted and that the relevant scripts and assets can load. A page’s load event is not a universal signal that every asynchronous element is ready; wait for a page-specific selector or condition where appropriate. - A full-page shot omits lazy content: Inspect the page’s loading behavior. Lazy images and sections may appear only after scrolling or other interaction, so prepare the page as needed before capture.
- An element screenshot fails or captures the wrong region: Check that the CSS selector identifies the intended element and that it exists in the rendered page at capture time. Use a more specific selector if it matches the wrong element.
- The image is too large or too small: Check the viewport dimensions and screenshot scale. Responsive layout is based on the page’s viewport; device-pixel scaling affects raster output dimensions.
- Transparency or format options do not behave as expected: Check the installed Playwright version’s Page API reference, and explicitly set the format and relevant options rather than relying on an inferred extension or defaults.
- A hosted request is rejected: For html2img, verify the API key and that a URL submitted to the URL endpoint is publicly accessible and valid. Consult the provider’s current docs for endpoint-specific requirements.
Performance, reliability, and cost considerations
With local Playwright rendering, the application is responsible for browser startup, page navigation, waiting for the content it needs, and closing the browser. Reusing a browser process across multiple captures may avoid repeated startup work, but the provided documentation does not quantify any performance gain; manage pages and browser resources deliberately and close them when finished. Capture time also depends on the page and its network resources, so a timeout or wait choice should reflect the content and environment rather than being treated as a guarantee.
A hosted renderer moves browser execution off your machine but adds a network request and service dependency. It also requires credentials and may impose provider-specific requirements. The cited materials do not provide comparable pricing, latency, or reliability measurements, so estimate those against your own workload and the vendors’ current terms rather than assuming one route will cost less.
Frequently asked questions
Can Python convert HTML that is not hosted online?
Yes. With Playwright, provide the markup to a page using page.set_content; the browser does not need a public URL for that workflow. A hosted URL-capture endpoint, by contrast, requires a publicly reachable URL according to html2img’s documentation, while its HTML endpoint accepts supplied markup.
Can I create a PDF instead of an image?
Playwright’s screenshot API is for image captures. ScreenshotNeo’s endpoint can return a PDF, and its MCP server includes a capture_pdf tool; use the service documentation for the relevant request options.
Which method produces better image quality?
The available documentation does not establish a quality ranking between local Playwright rendering and hosted services. In either workflow, output depends on the rendered page, viewport, assets, and capture settings; inspect representative results from your own content.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
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.

