Home › Image Tools › HTML to Image

HTML to Image

Paste an HTML snippet and its CSS, watch it render as you type, and export the result as a sharp PNG, JPG, WebP or SVG. Great for social cards, email banners, UI mockups, badges and documentation screenshots, all generated in your browser.

Last updated:

Edits render live. Scripts are not run; HTML and CSS only.

The checkerboard shows transparent areas. Only the content inside the preview frame is exported, so put backgrounds on your outer element (or pick a background above).

Advertisement
Advertisement

How to use the HTML to Image

  1. Pick a template or choose Blank, then paste your own HTML and CSS into the two editors.
  2. Set the width in pixels (leave it empty for auto) and add padding if you want space around the design.
  3. Choose the background: transparent for overlays and slides, or a solid color.
  4. Choose the format and scale. 2× gives a crisp image on phones and high-density screens.
  5. Download the image, or press Copy image to paste it into a chat, document or design tool.

How HTML becomes an image

Your HTML and CSS are rendered inside a sandboxed frame by the browser's normal layout engine, so flexbox, grid, gradients, shadows, rounded corners and pseudo-elements all look the way they do on a web page. To export, the open-source html-to-image library copies the element and its computed styles into an SVG foreignObject, then the browser paints that SVG onto a canvas at the scale you chose and encodes it as PNG, JPG or WebP. The output size is the element's size times the scale: an 800 × 420 px card at 2× becomes a 1600 × 840 px image.

Which format to choose

FormatTransparencyBest forNotes
PNGYesUI elements, badges, text-heavy cards, slidesLossless, sharp edges; larger files for photos
JPGNo (white fill)Cards with photos or gradients, emailSmallest for photographic content; quality slider
WebPYesWebsites and blogsLossless WebP is about 26% smaller than PNG on average, per Google
SVGYesWeb pages that need crisp zoomUses foreignObject; not supported by every design app

Tips for clean exports

  • Style an outer wrapper. Put the background, padding and border radius on one outer element. Styles on body are not part of the exported element.
  • Give the design a fixed width for social images: 1200 px wide for link previews or 1080 px for square posts, then export at 1×.
  • Leave room for shadows. A box-shadow outside the element is cut off; add a margin to the element or use the Padding option.
  • Prefer system fonts such as system-ui, Georgia or Arial for reliable results, or embed fonts as data: URLs.
  • Sharing code instead of a layout? Code to Image makes syntax-highlighted snippets, and HTML to PDF turns whole pages into documents.

Frequently asked questions

How do I convert HTML to an image?

Paste your HTML into the HTML box and your styles into the CSS box. The preview renders it with your browser's own layout engine. Then choose PNG, JPG, WebP or SVG and press Download. The image has exactly the size of the rendered element, multiplied by the scale you pick.

Can I get a PNG with a transparent background?

Yes. Keep Background set to Transparent and export PNG, WebP or SVG. Any area your own CSS does not paint stays transparent, which is shown as a checkerboard in the preview. JPG has no transparency, so it gets a white background.

Why are my images or web fonts missing from the export?

To draw external images and fonts into the picture, the browser must download them, and it can only do that when the other server allows cross-origin requests (CORS). Many sites do not. Use images from CORS-enabled hosts or data: URLs, and system fonts or fonts from services that send CORS headers.

Does JavaScript in my HTML run?

No. The preview is a sandboxed frame that blocks scripts, so pasted code cannot run or access the page. Content that only appears after JavaScript runs, such as charts drawn by a library, will not be shown. Export the static HTML and CSS instead.

What resolution should I use?

Use 1× when you need the exact pixel size, for example a 1200 px wide banner. Use 2× for images viewed on phones and retina screens, and 3× or 4× for print or slides that will be zoomed. Very large exports are limited to 16,384 pixels on each side by the browser.

Is the SVG export a real vector file?

The SVG wraps your HTML in a foreignObject element, so text and shapes stay sharp at any zoom in web browsers. Some design programs and Office apps do not support foreignObject; use a 3× or 4× PNG for those.

Is my code uploaded anywhere?

No. Rendering and image creation happen in your browser with the open-source html-to-image library. Your last HTML and CSS are kept only in this browser's local storage.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

Code to ImageTurn code into a beautiful syntax-highlighted PNG with themes, window frame and background.Screenshot BeautifierPut screenshots on gradient backgrounds with padding, rounded corners, shadow and a browser frame.HTML to PDF ConverterPaste HTML and CSS, preview it as pages and download a PDF, safely in your browser.Open Graph Image GeneratorDesign 1200x630 social share images with templates and live link previews, then export PNG.PSD to PNGConvert Photoshop PSD files to PNG and export every layer as its own PNG, no Photoshop needed.HEIC to JPGConvert iPhone HEIC photos to JPG.WEBP to JPGConvert WEBP images to JPG in bulk.PNG to JPGBatch convert PNG images to JPG with a background color.JPG to PNGBatch convert JPG images to PNG.WEBP to PNGConvert WEBP images to PNG, keeping transparency.SVG to PNGConvert SVG graphics to PNG or JPEG at any scale.PNG to ICOCreate multi-size favicon .ico files from PNG.AVIF to JPGConvert AVIF images to widely supported JPG.PNG & JPG to WEBPConvert PNG and JPG images to smaller WEBP files.PNG to SVG ConverterConvert PNG or JPG images to scalable SVG vectors with color and detail control.Image ConverterConvert images between JPG, PNG, WEBP, AVIF, BMP, GIF and ICO in batches, right in your browser.HEIC to PNGConvert iPhone HEIC and HEIF photos to lossless PNG in batches, with ZIP download.GIF to MP4Convert animated GIFs to MP4 video with loops, scaling and background color, in your browser.ICO to PNGExtract every size from ICO and CUR icon files and save them as PNG images or a ZIP.BMP to JPGBatch convert BMP bitmaps to small JPG files with a quality slider and ZIP download.JPG to SVGTrace JPG photos and logos into real vector SVG files with color and detail controls.SVG to JPGConvert SVG vectors to sharp JPG images at 1x to 8x or any width, with a background color.TIFF to JPGConvert TIFF and TIF images, including multi-page scans, to JPG with a quality slider.JFIF to JPGBatch convert .jfif images to standard .jpg files, re-encoded or lossless, with ZIP download.Camera Shutter Count CheckerFind your camera's shutter count from a JPG or RAW photo. Nikon, Pentax, some Sony and Canon.Film Negative to Positive ConverterTurn scanned color or B&W film negatives into positives with orange mask removal and auto balance.Convert Image to AVIFConvert JPG, PNG and WebP to AVIF with quality and speed control, size comparison and ZIP.Online Image ViewerOpen HEIC, TIFF, PSD, RAW, AVIF, WebP, ICO and more in your browser with zoom, pixel inspector and EXIF.Paste Image to FilePaste a clipboard image with Ctrl+V and save it as PNG, JPG or WebP, or copy images to the clipboard.RAW to JPGConvert camera RAW files (CR2, CR3, NEF, ARW, DNG, ORF, RAF, RW2) to JPG in batch, privately.Convert Image to CMYKConvert an RGB image to a CMYK TIFF or PDF for print, with ink limit, black generation and preview.Text to SVG PathTurn text in any Google or uploaded font into SVG path outlines for Cricut, laser and logos.AI to PNGConvert Adobe Illustrator .ai files to PNG at any DPI, with a transparent background, no Illustrator.CR2 to JPGConvert Canon CR2 RAW photos to JPG in batch: camera preview or developed sensor data.Image Format ComparisonCompress one image as JPG, WebP, AVIF and JPEG XL at the same quality and compare size and detail.PSD ViewerOpen Photoshop PSD files without Photoshop: browse layers, toggle visibility and export layers as PNG.Multi-Page TIFF ViewerView multi-page TIFF scans and fax files page by page, zoom, rotate and export pages as PNG or PDF.WEBP to GIFConvert animated or still WebP images to GIF, keeping every frame delay, with loop and size options.NEF to JPGConvert Nikon NEF RAW photos to JPG in batch: camera preview or developed sensor data.WEBP to MP4Turn animated WebP images into MP4 videos for sharing, with frame timing, length and size options.
See all 37 Image Converters →