HTML to Image — Convert HTML & CSS to PNG
Renders pasted HTML and CSS and captures it as a PNG at a chosen width and scale
Runs in your browser · nothing is uploaded
Paste a fragment (<div>…) or a whole document (<html>…). For a whole document, only the <body> content and <style> blocks are used.
Styles to add. <style> blocks inside the HTML apply as well.
The content is laid out at this width (px) and captured at its full height. 100–4000.
2× is sharp like a retina screen, 3× suits print. The pixel count grows with the square of the scale.
For security and privacy, images, fonts and CSS at any address other than data: or blob: are never requested, in the preview or during capture, and scripts never run. Text uses the fonts installed on your device.
Preview
Type some HTML to see the preview.
What it does
This tool saves a piece of HTML and CSS, such as a card, notice, table, button or email banner, as a PNG image. Use it to show rendered output in documentation or a blog post, to build a social media notice card in code, or to share part of a design as an image. Unlike cropping a screenshot, you get an exact width and scale.
How to use
- Paste code into HTML: a whole document (
<html>…) or just a fragment. New here? Click Insert example. - Optionally add styles under CSS.
<style>blocks inside the HTML apply as well. - Set the Capture width (px), Scale (1×, 2×, 3×) and Background (white or transparent).
- Check the preview, click Create PNG, then Save PNG.
How it works
- Safe preview: the code is drawn in a sandboxed iframe. The sandbox stops scripts from running, and a Content Security Policy blocks every network request except data: and blob: addresses.
- Outside addresses removed: the pasted code is first read by the browser’s own HTML and CSS parsers (nothing loads at this step). Every address that is not data: or blob: in src, srcset, poster, SVG href, style attributes,
<style>, url(), image-set(), @import and @font-face is removed and listed for you. Just before capture the preview is checked again, and while capturing only data: and blob: addresses can be read, so no request ever goes to an outside address. Links (<a href>) do not affect the picture, so they are not listed; they are changed so that clicking them goes nowhere. - Capture size: the content is laid out at the chosen width and captured at its real height. The PNG is width × scale by height × scale.
- Size limit: above what the browser can handle (16,777,216 pixels on iPhone and iPad, 16,384 px per side) the scale is lowered automatically and the page says so.
- Whole documents: only the
<body>content and every<style>block are used; other<head>tags are dropped. - Capturing uses html-to-image (MIT licence).
Examples
| Input | Settings | Result |
|---|---|---|
| The example notice card | Width 800, 2× | PNG 1600 px wide |
A <table> with CSS |
Width 600, 3×, transparent | PNG 1800 px wide, transparent background |
| Code with an outside image | Width 800, 1× | The outside image stays empty; blocked addresses are listed |
For vector drawings, use SVG to PNG; for Markdown, try the Markdown preview.
FAQ
Can I capture a website by its URL?
No. Capturing another site needs a server to open the page on your behalf, which this tool does not do. Paste HTML and CSS you wrote or copied from your browser's developer tools.
Images are missing.
For security and privacy, images, fonts and CSS at any address other than data: or blob: (http, https, // and relative paths) are never loaded. Addresses hidden with HTML character references or CSS escapes are checked as the browser decodes them, so they are blocked too. The tool lists the blocked addresses; embed images as data: (Base64) addresses and they appear. The image to Base64 tool can create them.
The font looks different from my design.
Web font files are not fetched, so text uses the fonts installed on your device. If the named font is missing, the system default (for example Segoe UI on Windows, San Francisco on Apple devices) is used.
Does content generated by JavaScript appear?
No. Scripts in the pasted code are not run; only static HTML and CSS are drawn.
Is my code sent to a server?
No. The preview and the image are both made in your browser.
Related tools
SVG to PNG
Browser converter from SVG to PNG, JPG or WebP with scale or width
Markdown Preview
A live Markdown editor with sanitized HTML you can copy or save
Image to Base64
Browser converter between images and Base64, data URIs, CSS and HTML snippets
HTML Entity Encoder/Decoder
Encode and decode HTML entities for special and non-ASCII characters
HTML to PDF
Turn HTML code into a PDF with the paper size and margins you choose