Rendering self-contained HTML and CSS to PNG locally
Generating social preview cards, KPI badges, or invoice summary graphics usually forces teams to boot a headless Chromium container or send private markup to a screenshot API. This browser utility renders self-contained HTML and CSS into PNG, JPG, or WebP inside your current tab. Zero markup, class names, or embedded customer metrics ever touch a remote server.
Strict XHTML normalization inside SVG foreignObject
Under the W3C SVG 2 Embedded Content Specification, an SVG <foreignObject> container hosts an http://www.w3.org/1999/xhtml subtree inside a bounded vector viewport. Loose HTML5 habits such as unclosed <img>, <br>, or <hr> tags break strict XML parsing immediately.
To prevent syntax failures, the built-in tokenizer normalizes void elements, auto-closes implicit <p> or <li> siblings, and escapes stray ampersands before painting. When your source starts as prose or GFM tables rather than raw tags, turn Markdown & READMEs into crisp PNG or JPG cards instead.
Viewport presets, 2x Retina scale, and batch ZIP export
Testing responsive cards across screen breakpoints takes one click between 375, 800, 1200, or Custom (200 to 2400 px). Leave Scale on 2x to export crisp Retina graphics (1600 px wide for an 800 px card, plus outer padding).
Dropping two or more .html files (up to 10 MB each) opens a batch queue where you can click any filename to preview it. Selecting Save image renders every queued file with your active settings and packs them into html-images.zip.
When should you export HTML as PNG vs JPG or WebP?
Export HTML as PNG whenever your component relies on crisp UI typography, 1-pixel borders, or transparent rounded corners that paste cleanly into Figma, Slack, or slide decks. Choose WebP for lightweight web publishing with alpha transparency, or JPG when sharing opaque photographic banners where smaller byte size matters most.
Under the W3C PNG Third Edition Specification, truecolor-with-alpha PNG stores lossless 8-bit transparency without chroma subsampling artifacts around sharp text. If you need mathematical equations typeset with Computer Modern glyphs instead of manual HTML markup, try the formula to image tool.
| Format | Alpha transparency | Compression mode | Default quality | Best HTML and CSS use case |
|---|---|---|---|---|
| PNG | Full 8-bit alpha | Lossless Deflate | Lossless | UI cards, badges, dark-mode stickers, crisp 1 px borders |
| WebP | Full 8-bit alpha | Lossy or lossless | 0.92 |
Blog diagrams, lightweight docs, smaller transparent assets |
| JPG | Opaque white or custom hex | Lossy DCT | 0.92 |
Photographic hero cards, newsletter banners without transparency |
| Copy PNG | Full 8-bit alpha | Lossless clipboard | Lossless | Direct pasting into Slack, Notion, Figma, or slides |
Why are external stylesheets and remote images blocked?
All <script> tags, <iframe> elements, @import rules, and http:// or https:// subresource URLs are stripped before rendering so nothing leaves your browser and the 2D canvas stays origin-clean. Any external URL inside an SVG <foreignObject> taints the canvas and blocks pixel export.
Preventing canvas tainting and side-channel data leaks
Browser security models isolate <foreignObject> subtrees so malicious markup cannot probe cross-origin cookies, :visited link styles, or remote servers during rasterization. According to the MDN HTMLCanvasElement.toBlob() API Reference, calling toBlob() throws a SecurityError whenever a canvas has been tainted by cross-origin resources.
Because the sanitizer removes remote URLs, inline on* handlers, and javascript: links before building the SVG, your browser produces a clean PNG, JPG, or WebP blob every time. A status banner below Live preview reports the exact count of stripped external URLs whenever remote links were skipped.
Embedding inline SVG icons and Base64 data: URIs
Self-contained assets work offline without triggering network requests or canvas security blocks. You can inline <svg> icons directly in the markup, or encode local PNG, JPEG, GIF, WebP, or AVIF assets as data:image/* URIs inside img src or CSS url(...).
Before pasting large vector icons into your HTML snippet, shrink inline SVG icons before embedding to keep the payload compact. Custom typography works the same way when embedded as Base64 data:font/woff2 rules inside an inline <style> block.
CSS layout behavior, Shadow DOM sizing, and troubleshooting
Your browser’s native layout engine computes CSS Grid, Flexbox, custom properties, linear gradients, border-radius, and box-shadow directly at your chosen viewport width. Media queries respond immediately as you switch between 375 px, 800 px, and 1200 px presets.
Root selector rewriting and closed ShadowRoot measurement
Full HTML documents often attach background colors or typography rules to html or body selectors, which do not exist inside an SVG <foreignObject> <div> wrapper. The sanitizer automatically rewrites standalone html and body CSS preludes to .ht-html-root so page-level styles still apply.
Height calculation runs inside a hidden closed ShadowRoot using XML DOMParser before rasterization. As documented in the MDN Element.attachShadow() Documentation, closed Shadow DOM encapsulates layout measurement from host page styles without executing scripts.
Fixing clipped containers and missing web fonts
If an element overflows vertically or renders with unexpected system fonts, inspect Live preview before exporting. Check the computed pixel dimensions above the preview box (width×height px including 0 to 128 px padding at 1x or 2x scale) to confirm nothing is clipped.
Tip: Replace fixed
height: 100vhrules withmin-heightor explicit pixel heights, and inline any CSS variables from external stylesheets so colors and spacing match your production build.
When you need selectable text, hyperlinks, or multi-page print pagination instead of a raster screenshot, switch to HTML to PDF.