html2image
Package acting as a wrapper around the headless mode of existing web browsers to generate images from URLs and from HTML+CSS strings or files.
What it is and what it does
html2image wraps the headless rendering mode of Chrome, Chromium, or Edge to convert HTML, CSS, and web URLs into image files. It abstracts away the complexity of invoking browser command-line interfaces, letting you generate screenshots from HTML strings, local files, or live URLs with a simple Python API. The package handles temporary file management, supports batch operations, and allows customization of output size, format, and browser flags.
The main use case is automated screenshot generation for testing, documentation, or content creation. It depends on requests and websocket-client for network operations, and requires a compatible browser binary installed on the host system. The package is actively maintained, supports Python 3.6 through 3.13, and has no known security vulnerabilities.
Use it for:
- Generate screenshots of live websites for automated testing or visual regression detection.
- Convert HTML email templates or reports to images for archival or distribution.
- Create PNG thumbnails from HTML/CSS designs without manual browser interaction.
- Batch-process multiple HTML files or URLs into images with consistent sizing and styling.
- Render SVG and other vector formats to raster images via browser headless mode.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Generates PNG/image files from HTML, CSS, and URLs by wrapping headless browser rendering (Chrome, Chromium, or Edge).
Yes. Low install friction, permissive MIT license, active maintenance, no known vulnerabilities, and broad Python version support (3.6–3.13). Install only if you have a compatible browser (Chrome, Chromium, or Edge) available on your system; otherwise, the package will fail at runtime. Suitable for production use in testing, documentation, and content pipelines.
Install
html2image on PyPI
pip
pip install html2imageuv
uv add html2imagepoetry
poetry add html2imageInstalling html2image
Before you install
Low friction: only two runtime dependencies (requests, websocket-client). Active maintenance with recent commits; last release 2025-05-16. Requires an external browser binary (Chrome, Chromium, or Edge) installed on the system to function.
License in practice
MIT License permits commercial and private use, modification, and distribution with minimal restrictions. Include a copy of the license and copyright notice in distributions.
Quickstart
pip install html2image
from html2image import Html2Image
hti = Html2Image()
hti.screenshot(url='https://www.python.org', save_as='page.png')
# or from HTML string:
hti.screenshot(html_str='<h1>Hello</h1>', css_str='body {background: blue;}', save_as='output.png')
Requires Chrome, Chromium, or Microsoft Edge installed and accessible on the system PATH or via browser_executable parameter.
Verify before relying
- Performance characteristics when rendering complex or large HTML documents.
- Memory usage and resource overhead for batch screenshot operations.
- Compatibility with specific browser versions or rendering edge cases.
Package facts
| License | MIT License Copyright (c) 2020 vgalin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — requests, websocket-client |
| Maintenance | actively maintained — 455 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 432,002/month — #6,711 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: html2image-2.0.7-py3-none-any.whl
Keywords: chrome, chromium, chromium-browser, css, css to image, html, html to image, image, screenshot
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
nokapnokap captures screenshots and PDFs from web…
permissive · top 15,000 on PyPI
screenshotoneA Python SDK for the ScreenshotOne.com API that…
permissive · top 15,000 on PyPI
pyppeteerAutomates headless Chrome/Chromium browser…
permissive · top 5,000 on PyPI
airiumAirium generates HTML from Python code using…
permissive · top 15,000 on PyPI
imgkitimgkit wraps the wkhtmltoimage command-line…
permissive · top 15,000 on PyPI
mycdpMyCDP provides autogenerated Chrome DevTools…
permissive · top 15,000 on PyPI
Selenium-ScreenshotCaptures full-page or element-level screenshots…
permissive · top 15,000 on PyPI
browserforgeGenerates realistic browser headers and device…
permissive · top 5,000 on PyPI
weasyprintWeasyPrint converts HTML and CSS into PDF…
permissive · top 1,000 on PyPI
kaleidoKaleido generates static images (PNG, SVG, PDF,…
unclear · top 5,000 on PyPI