Skip to content

HTML to image: turn pasted HTML and CSS into a PNG or JPG

Paste a piece of HTML with its CSS, such as a social media card, a price table, a banner or an email block, and save it as a PNG or JPG. Choose the width the layout should have, let the height follow the content or fix it, and pick 1×, 2× or 3× for sharp text on high-density screens. Arabic and other right-to-left text is shaped and laid out correctly. The page is drawn by your own browser, and nothing you paste is uploaded.

Quick answer

Paste your HTML and CSS, pick a width such as 1200 px and, if you need an exact size, a fixed height such as 630 px. Check the live preview, choose PNG or JPG and a scale, then press Convert. Scripts are removed and nothing outside the page is loaded, so add any images from your device with the Add images button and refer to them by file name.

Rendered in your browser, never uploaded

Based on MDN Web Docs, <foreignObject> SVG element (last modified 6 June 2025) · Page updated 23 October 2026

Editor: Abuzar, founder of NeedMyToolsHow we check facts

Try:

Scripts do not run and nothing is loaded from other websites: no outside images, fonts or stylesheets. A web address cannot be captured here.

Files you add are used where your HTML or CSS names them, for example src="logo.png" on an image or url(font.woff2) in CSS. They stay on this device.

Height
Scale
Format

Preview

Paste HTML to see the preview.

How to use the HTML to image

  1. Paste your HTML into the box. A full page with <html>, <head> and <style> works, and so does a single <div> with a <style> block above it. Try one of the samples to see the format.
  2. If your HTML uses pictures or a font file, press Add images and choose them from your device; an <img src="logo.png"> or url(font.woff2) then uses the file with that name.
  3. Choose the width, auto or fixed height, scale, format, background and text direction, and check the preview.
  4. Press Convert, look at the result and download the PNG or JPG.

How the HTML is turned into an image

Browsers can draw HTML inside an SVG picture through the SVG <foreignObject> element, which holds content from another XML namespace, in practice XHTML. The converter first cleans your HTML and shows it in a sandboxed preview frame at the width you chose, where it measures the height of the content. It then copies that document into a <foreignObject> of the same size, lets the browser draw the SVG on a canvas at 1, 2 or 3 times the size, and saves the canvas as PNG or JPG. Because the browser's own layout engine does the work, flexbox, grid, gradients, rounded corners, shadows, tables and web-safe or system fonts come out as they look in the preview. A 1200 × 630 card at 2× becomes a 2400 × 1260 image with crisp text.

What it cannot do: web addresses, scripts and outside files

This tool does not take a website address. Capturing a live page from a URL means opening that page on a server, running its scripts and photographing the result, and we do not run a server that visits addresses for visitors. Copy the HTML you need instead, or for a page you can see, use your browser's own screenshot command. For the same safety reasons, pasted scripts and event handlers are removed and do not run, and frames, objects and external stylesheets are dropped. Images, fonts and stylesheets on other websites are not fetched: an SVG drawn as an image may not load outside resources, and the preview frame blocks them as well, so the result matches the preview. Each blocked address is listed above the preview. Images and fonts you add from your device are placed inside the page as data URLs, which are allowed.

Width, height, scale and file size

The width is the layout width in CSS pixels, the same as the width of a browser window, so a page with media queries shows its mobile layout at 360 px and its desktop layout at 1280 px. With auto height the image is exactly as tall as the content; a fixed height crops or pads the bottom, which is what you want for a social card with a set size, such as 1200 × 630 or 1080 × 1080. The scale multiplies both sides: 2× has four times the pixels of 1×. Browsers limit the size of a canvas, so the converter keeps each side within 16,384 px and the total within 100 million pixels; if 3× would go past that it lowers the scale and tells you, and a page taller than 16,384 px is cut at that height. PNG keeps text sharp and allows a transparent background. JPG is smaller for photos and gradients but has no transparency, so a background colour is always filled.

Arabic and right-to-left layouts

Arabic letters are joined and shaped by the browser, so they look as they would on a web page. If your HTML has no dir attribute and most of its letters are Arabic, the converter sets the page to right to left; you can also choose left to right or right to left yourself. Use CSS logical properties such as margin-inline-start and text-align: start so one design works in both directions. Fonts are the ones installed on your device unless you add a font file. That means an Arabic design may look slightly different on another computer with other fonts, so for a brand font add the .woff2 or .ttf file and name it in @font-face with url(yourfont.woff2). Numbers inside Arabic text keep their order, and mixed Arabic and English lines follow the normal bidirectional rules of the browser.

Ideas for using HTML as an image

Designers and developers use HTML to make images that are easier to edit as code than in a drawing program: link preview cards for articles, quote cards, a price list for a shop window or WhatsApp, certificate headers, charts made with CSS, and screenshots of a component for documentation. For a share image, set the width to 1200 and the fixed height to 630, then check the tags that point to it with our meta tag generator. Vector graphics already saved as SVG files are better converted with SVG to PNG. To shrink the result before you upload it, use compress image; to change its size later, use resize image. More image tools are on the image tools page.

Frequently asked questions

Can I convert HTML to an image without uploading my code?

Yes. The HTML is cleaned, laid out and drawn by your own browser, and the PNG or JPG is made on your device. Nothing you paste or add is sent anywhere.

Can I take a screenshot of a website from its URL here?

No. Capturing a page from an address needs a server that opens the page, and this tool works only in your browser. Paste the HTML instead, or use your browser's screenshot command.

Why are the images in my HTML missing from the result?

Images on other websites are not loaded, for privacy and because an SVG drawn as an image cannot fetch them. Press Add images, choose the files and keep the same file names in your src attributes.

Does JavaScript in my HTML run before the image is made?

No. Script tags, onclick and other event handlers and javascript: links are removed. Content that a script would add, such as a chart drawn by a library, will not appear.

What size should an HTML image be for a link preview?

A width of 1200 px with a fixed height of 630 px is a common size for share images. At 2× scale you get a 2400 × 1260 PNG that stays sharp when sites resize it.