Skip to content

HTML to Image

✨ Preview updates as you type 0 lines · 0 B

Image

Background

Paste HTML on the left

You’ll see the picture here, at the size it will be saved
Nothing to convert yet

HTML to Image Converter – Save HTML as PNG, JPG or WebP

What is an HTML to Image Converter?

It turns a piece of HTML and CSS into a picture file. You paste the code, pick how wide the page should be, and download a PNG, JPG or WebP that looks just like the preview. It’s handy when you’ve built something in HTML but need it somewhere that only takes images: a social media post, a slide, a README, a chat message or a design review.

Everything happens in your browser. Your HTML isn’t uploaded anywhere, and the picture is saved straight from this page. If you need a document with pages instead of one picture, the HTML to PDF converter is the one to use.

How to Convert HTML to an Image – Step by Step

Five short steps. Click Sample in the tool above to follow along with a social card.

Step 1 Paste or Open Your HTML

  • Paste it: a snippet, a full page, or the source of a page (Ctrl+U shows it in most browsers).
  • Open an HTML file: click the upload button, or drag the .html file onto the tool.
  • Click Sample: loads a 1200 × 630 announcement card, the size social sites use for link previews.

The preview on the right updates as you type, and your code is still there after a reload.

Step 2 Pick the Width and Height

Width works like the width of a browser window. Your page is laid out at that width, so its media queries react the same way they would on a phone (375 px), a tablet (768 px) or a desktop (1920 px). Custom takes any width from 100 to 4000 px.

Height: Full page makes the picture as tall as your content. The page is laid out in a window 900 px tall first, so 100vh counts as 900 px, and then everything below is added. Fixed cuts it at the height you type, like a screenshot of the top of the window. 1200 × 630 is the usual size for a link preview image.

Step 3 Choose the Scale and Format

  • Scale multiplies the pixels. At 2x (the default) a 1200 px page becomes a 2400 px picture, which stays sharp on phones and high-resolution screens. 1x makes the smallest file, 3x the sharpest.
  • Format: PNG for text and graphics, JPG or WebP for smaller files. JPG and WebP get a Quality slider: lower means a smaller file with softer details.

The status line under the preview shows the final size in pixels before you download.

Step 4 Background, Element and JavaScript

  • Background: Page keeps your page’s own background (white if it has none), White swaps it for plain white, and Transparent leaves it out, so the picture is see-through behind your content (PNG and WebP only).
  • Element: type a CSS selector like .card or #hero to capture just that element. The preview outlines it with a dashed line.
  • JavaScript (off by default) lets your page’s scripts run first. The tool then waits 1 second before taking the picture, so a chart or a list filled in by a script has time to appear. While it’s off, embedded frames (like a video player) don’t load in the preview either.

Step 5 Download or Copy

  • Download image (the lime button) saves the file. Name it in the File box, or leave it empty to use the page’s <title>.
  • Copy image puts a PNG on your clipboard, so you can paste it right into a chat, an email or a document with Ctrl+V. It shows up in browsers that allow copying pictures.

After each picture you’ll see its exact size in pixels and its file size.

What You Can Use It For

Social cards and link previews

Design the card in HTML at 1200 × 630, download it as a PNG and point your og:image tag at it. The Meta Tag Generator writes those tags for you.

Code snippets as images

Put your code in a dark window with a colored frame, capture just the frame, and share it on a slide or in a post. Try the example below.

Email previews

Turn an HTML email into a picture to show a client or to put in a design review. Check how it looks on phones first with the HTML Email Viewer.

Screenshots for docs

Capture a component at a fixed width for a README or a help page. Every picture comes out the same size, so they line up nicely.

Buttons, badges and banners

Make a button or a badge with a transparent background and use it anywhere an image goes, like a slide or an app store page.

Checking a layout

Save the same page at 375, 768 and 1366 px to compare them side by side. For a live view of all sizes at once, use the Responsive HTML Viewer.

Try it: a code snippet as an image

The whole example is a page with a green frame around a code window. The Element box is set to .frame, so the picture is just the frame.

<div class="frame">
  <div class="window">
    <div class="dots">…</div>
    <pre><code>function greet(name) { … }</code></pre>
  </div>
</div>

Try it: a badge with a transparent background

Element .badge, Background Transparent and 3x. The round ends of the badge come out see-through, so it sits nicely on any color.

<span class="badge">
  <b>New</b> Dark mode is here
</span>

PNG, JPG or WebP: Which One?

PNGJPGWebP
Best forText, logos, code, flat colorsPhotosBoth, when file size matters
Sharp text edgesYesSlightly softYes at high quality
Transparent backgroundYesNo (white instead)Yes
File sizeLargestSmallSmallest
Opens everywhereYesYesIn every modern browser and most apps

Not sure? Pick PNG. If the file is too big to upload somewhere, try WebP or JPG at about 85% quality. The WebP option only shows when your browser can make WebP files.

Tips for a Sharp, Good-Looking Picture

Use 2x for anything with text

At 1x, text looks soft on most phones and laptops. 2x doubles the pixels in each direction and keeps letters crisp. Use 1x only when the picture will be shown small or the file has to be tiny.

Give your design a fixed width

If your card has width: 1200px, pick the 1200 px width so nothing is cut or left empty at the side. A design without a fixed width simply fills whatever width you pick.

What Transparent leaves out

Transparent removes the html and body backgrounds. Backgrounds on your own boxes stay, so a card keeps its color and only the space around it becomes see-through.

Leave room for shadows

An element’s box doesn’t include its shadow, so a captured card loses it. Put the card in a wrapper with some padding and capture the wrapper.

Fonts

System fonts always work. Web fonts from Google Fonts work too. If your font doesn’t show up, its site probably doesn’t allow other sites to use it, so the picture falls back to a system font.

Full image addresses

Relative paths like images/logo.png can’t load here, because the tool only has your HTML. Use a full https:// address or a data: URL.

Example: a social card, and a shadow that survives

A 1200 × 630 card:

/* The size social sites use for link previews */
.card {
  width: 1200px;
  height: 630px;
  box-sizing: border-box;
  padding: 64px;
}

Capture .wrap, not .card:

/* The element box doesn't include its shadow,
   so give the shadow room inside a wrapper */
.wrap { display: inline-block; padding: 40px; }
.card { box-shadow: 0 20px 40px rgb(0 0 0 / 30%); }

Images that work and one that doesn’t:

<!-- Works: a full address on a site that allows it -->
<img src="https://images.example.com/team.jpg" alt="Our team">

<!-- Works anywhere: the picture is inside the HTML -->
<img src="data:image/png;base64,iVBORw0KGgo…" alt="Logo">

<!-- Doesn't work here: the tool doesn't have this file -->
<img src="images/logo.png" alt="Logo">

What It Can’t Do

Frequently Asked Questions

How do I convert HTML to an image?

Paste your HTML into the box on the left, or open an .html file. Pick the width (1200 px is a good start for a social card), Full page or a fixed height, and the scale. Check the preview on the right, then click Download image. You get a PNG unless you pick JPG or WebP under Format.

Should I pick PNG, JPG or WebP?

PNG for anything with text, logos, buttons or code: it keeps sharp edges and can have a see-through background. JPG for pages that are mostly photos, because the file is much smaller, but it can’t be transparent. WebP makes small files like JPG and can be transparent like PNG, and every modern browser opens it. If you’re not sure, PNG is the safe choice.

Why does the picture look blurry?

Most phones and many laptops have screens with two or three pixels for every CSS pixel. A 1x picture has one, so it looks soft on those screens. Pick 2x (the default) or 3x and the picture has two or three times as many pixels in each direction. A 1200 px wide page at 2x becomes a 2400 px wide image that stays crisp.

How do I make a PNG with a transparent background?

Pick PNG or WebP, then Background: Transparent. The page and body backgrounds are left out, and the preview shows a checkerboard where the picture will be see-through. To get just a button or a card with round corners and nothing around it, also type its selector (like .card) in the Element box. JPG can’t be transparent, so there the background is white.

Can I make a picture of only one part of the page?

Yes. Type a CSS selector in the Element box, like .card, #hero or main > section:first-child. The preview outlines that element and dims the rest, and the picture is exactly its box. If more than one element matches, the first one is used. Shadows that spill outside the element are cut off, so wrap it in a div with some padding and capture the div instead.

Why is an image or a font missing from my picture?

To draw the picture, the tool has to read every image and font file. It can only do that when the website they come from allows other sites to use them (this is called CORS). If it doesn’t, the image comes out blank and the tool tells you how many were left out. Pictures put in the HTML as data: URLs always work, and so do Google Fonts. Relative paths like images/logo.png can’t work, because the tool only has the HTML you pasted, not the files next to it.

Is my HTML uploaded anywhere?

No. The preview and the picture are both made in your browser, and the file is saved straight from there. The only requests are the ones your HTML makes itself, like loading its images, fonts or stylesheets. Your code is kept in this browser’s storage so it’s still there after a reload; Clear removes it.

Does it run the JavaScript in my HTML?

Only if you tick JavaScript. It’s off by default, so scripts and onclick handlers are removed first. Turn it on when your page builds its content with JavaScript, like a chart. The scripts run, then the tool waits one second before taking the picture. Either way the code runs in a locked-down frame that can’t reach this website, your cookies or anything else on your computer.

Can I take a screenshot of a website by its URL?

Not here. Browsers don’t let one website read the pages of another, so a tool running in your browser can’t load a page by its address. Open the page, press Ctrl+U (Cmd+Option+U on a Mac) to see its source and paste it in, or save the page as an .html file and open it with the upload button. Images on that page only show up when their site allows it.

Why didn’t it work in Safari?

Safari can block a page from reading a picture it drew from HTML, which is the step this tool needs. When that happens you’ll see a message instead of a download. Chrome, Edge and Firefox work, or you can take a screenshot of the preview with your computer’s own screenshot tool.