What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The right way to convert HTML to an image depends on where the code runs and how exact the result must be. Use html2canvas in a browser for an export button that captures an existing component; use Playwright or Puppeteer when you need a real browser render, JavaScript execution and server-side control; or use a hosted HTML-to-image API when you do not want to operate browser infrastructure. The methods below show complete implementations, format choices, cross-origin limits and fixes for incomplete captures.

Choose the rendering method first

Method Runtime Visual fidelity Best use Main limitations
html2canvas Visitor’s browser Approximate DOM reconstruction “Export this component” buttons and same-origin content Unsupported CSS, cross-origin assets, iframes and canvas-size limits
Playwright or Puppeteer Managed server or local process Real browser layout JavaScript-heavy pages, authenticated routes and production screenshots You operate a browser runtime and must manage waits, resources and security
Hosted HTML-to-image API Provider’s infrastructure Depends on provider’s browser Teams that want an HTTP interface instead of browser operations Service cost, authentication, retention and availability depend on current terms

Decide whether you need a viewport image, a selected element or the entire document. Full-page images can become very large, so set an explicit viewport and output policy before sending them to storage or another API.

Convert an element in the browser with html2canvas

html2canvas walks the DOM and paints a canvas representation. Its documentation cautions that “The screenshot is based on the DOM and as such may not be 100% accurate to the real representation.” It is therefore convenient, but it is not the same as a native browser screenshot.

Install or load the library

For a simple page, load the browser build:

<script src="https://cdn.jsdelivr.net/npm/html2canvas@1.4.1/dist/html2canvas.min.js"></script>

For a bundled application, install it with your package manager:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
npm install html2canvas

Capture one element and download a PNG

<button id="save-card">Save card</button>
<section id="card" class="card">
  <h1>Monthly report</h1>
  <p>Revenue increased 18%.</p>
</section>
<script>
  document.querySelector('#save-card').addEventListener('click', async () => {
    const element = document.querySelector('#card');
    const canvas = await html2canvas(element, {
      backgroundColor: '#ffffff',
      scale: window.devicePixelRatio,
      useCORS: true
    });
    canvas.toBlob(blob => {
      if (!blob) throw new Error('Canvas export failed');
      const link = document.createElement('a');
      link.download = 'monthly-report.png';
      link.href = URL.createObjectURL(blob);
      link.click();
      URL.revokeObjectURL(link.href);
    }, 'image/png');
  });
</script>

html2canvas(element) returns a canvas. Use canvas.toDataURL() for a data URL or canvas.toBlob() for a downloadable file or upload. Set backgroundColor: null for transparency where the browser and source styles permit it. A higher scale increases sharpness and pixel count, but also memory use.

Make the client-side result predictable

  • Wait until the component is visible and its data has rendered before calling the function.
  • Wait for fonts and images. A capture started during font swapping can contain fallback glyphs.
  • Use useCORS: true only when remote images send compatible CORS headers; this option cannot bypass browser security.
  • Keep remote iframes and images same-origin, or proxy them through your own origin with correct headers. Otherwise they may be omitted or “taint” the canvas, preventing export.
  • Reduce the element’s dimensions or scale if the browser reports a canvas-size or memory error. Canvas limits vary by platform.

html2canvas does not execute a second browser layout. Unsupported CSS, filters, pseudo-elements, embedded documents and cross-origin resources can differ from what the user sees.

Take a real browser screenshot with Playwright

Playwright drives Chromium, Firefox or WebKit and captures the browser’s rendered output. That makes it the stronger choice for server-side jobs, authenticated pages and JavaScript applications. Install it with:

npm install playwright
npx playwright install chromium

Capture a URL as WebP, PNG or JPEG

import { chromium } from 'playwright';

const browser = await chromium.launch();
const page = await browser.newPage({
  viewport: { width: 1440, height: 900 },
  deviceScaleFactor: 1
});

await page.goto('https://example.com/report', { waitUntil: 'networkidle' });
await page.evaluate(() => document.fonts.ready);
await page.screenshot({
  path: 'report.webp',
  type: 'webp',
  fullPage: true
});
await browser.close();

Playwright supports PNG, JPEG and WebP. Use fullPage: false (the default) for the viewport only. For a component, locate it and capture its bounding box:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
await page.locator('#card').screenshot({ path: 'card.png', type: 'png' });

Use a selector wait when asynchronous content has a known completion marker:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
await page.goto('https://example.com/dashboard', { waitUntil: 'domcontentloaded' });
await page.locator('[data-rendered="true"]').waitFor();
await page.screenshot({ path: 'dashboard.png', fullPage: true });

Control authentication, media and output

Create the browser context with cookies or an HTTP header before navigation:

const context = await browser.newContext({
  viewport: { width: 1280, height: 800 },
  colorScheme: 'dark',
  locale: 'en-US',
  timezoneId: 'America/New_York',
  extraHTTPHeaders: { Authorization: `Bearer ${process.env.TOKEN}` }
});
const page = await context.newPage();
await page.goto('https://example.com/private', { waitUntil: 'networkidle' });

Set page.emulateMedia({ media: 'screen' }) when print styles would otherwise be selected. Hide animations or replace volatile content with CSS before capture if deterministic output matters. Close the context and browser in a finally block in production so failures do not leak processes.

Use Puppeteer when your stack already uses Chrome

Puppeteer provides a similar real-browser path and documents Page.screenshot. Install it with npm install puppeteer; the package supplies a compatible Chrome for typical installations.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({ headless: true });
  try {
    const page = await browser.newPage();
    await page.setViewport({ width: 1365, height: 768, deviceScaleFactor: 1 });
    await page.goto('https://example.com', { waitUntil: 'networkidle2', timeout: 60000 });
    await page.evaluate(() => document.fonts.ready);
    await page.screenshot({ path: 'page.png', fullPage: true, type: 'png' });
  } finally {
    await browser.close();
  }
})();

Choose one automation library for a service rather than launching a new browser for every request. Reuse a browser process, create isolated contexts for users, cap concurrent pages, and set navigation and overall job timeouts. Treat arbitrary URLs as untrusted: restrict network access, prevent access to internal metadata endpoints, and enforce output-size limits.

HTML strings, templates and PDFs

For an HTML string that is not yet hosted, create a document directly in the browser:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
const html = `<!doctype html><html><head><style>body{font:16px sans-serif}</style></head><body><h1>Invoice</h1></body></html>`;
await page.setContent(html, { waitUntil: 'networkidle' });
await page.evaluate(() => document.fonts.ready);
await page.screenshot({ path: 'invoice.png', fullPage: true });

Inline images as data URLs or serve them from an origin reachable by the browser. For a PDF instead of an image, Playwright’s page.pdf() supports paper size, margins, landscape and page ranges; choose PDF when selectable text and pagination matter more than a raster image.

Image format and capture options

  • PNG: lossless and suitable for interfaces, text, diagrams and transparency.
  • JPEG: smaller for photographic pages, but lossy and without transparency.
  • WebP: often a practical size-quality compromise when every consumer supports it.

For a stable result, specify viewport width and height, device scale factor, color scheme, locale, timezone and any required authentication. Choose element capture for cards or charts, viewport capture for what a user sees, and full-page capture only when the entire document is required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Or skip the browser setup

ScreenshotNeo is a hosted screenshot API and MCP server. It accepts a URL and returns PNG, JPEG, WebP or PDF. Before capture it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status.

One request is enough:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the complete parameter list in the ScreenshotNeo documentation. The same endpoint supports full-page and CSS-selector capture, dark mode, 12 device presets or a custom viewport, retina scale, PDF paper settings, custom CSS and JavaScript, pre-capture clicks, selector or network-idle waits, ad/tracker/request blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, a chosen cache TTL, signed image links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));

An MCP server lets Claude, Cursor and other MCP clients call take_screenshot, get_page_info and capture_pdf without your application embedding a browser. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to start.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting incomplete or incorrect images

Fonts or images are missing

Capture began before resources finished. Await document.fonts.ready, wait for a specific image or readiness selector, and make sure the resource URL is reachable from the rendering environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The canvas is tainted or remote content disappears

This is a CORS or same-origin issue. Configure the image server’s CORS headers, proxy the asset through your origin, or switch to Playwright or a hosted renderer that can access the page legitimately. html2canvas cannot bypass browser content policies.

The result differs from the visible page

html2canvas reconstructs the DOM and may not implement a CSS feature, iframe or filter. Use a real-browser screenshot for layout fidelity, and explicitly set viewport, color scheme and device scale factor.

Full-page capture is blank, clipped or too large

Measure the document and capture in sections, lower the scale, or use a viewport image. Browser canvas dimensions and total pixel area have platform-dependent limits.

Server jobs hang

Use navigation and job timeouts, wait for a bounded readiness condition instead of indefinite network idle, block unnecessary resources, and always close pages, contexts and browsers. Retry only idempotent captures and record the URL, viewport and wait condition with each job.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Authenticated content is logged out

Supply cookies, an Authorization header or a pre-authenticated browser context before navigation. Never place long-lived credentials in a public client-side script.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Operational checklist

  1. Define whether the output is an element, viewport or full document.
  2. Set viewport, scale, color scheme, locale and timezone explicitly.
  3. Wait for fonts, images and application data.
  4. Choose PNG, JPEG or WebP according to transparency, text and size needs.
  5. Validate cross-origin resources and iframe behavior.
  6. Set timeouts, output limits and cleanup handlers.
  7. Protect credentials and sandbox arbitrary URL capture.
  8. Store the page verdict, output format and capture errors for diagnosis.

FAQ

Can I convert HTML to an image without JavaScript?

Yes. A browser automation script or hosted API can render a URL or HTML string without adding a client-side export button. The rendering engine still executes the page’s HTML, CSS and, where applicable, JavaScript.

Which method is best for a React or Vue dashboard?

Use Playwright or Puppeteer for a server-generated, faithful dashboard image. Use html2canvas when the user is already viewing the dashboard and an approximate client-side export is acceptable.

Should I capture at 2× resolution?

Increase device scale factor or html2canvas scale when the image will be displayed larger or printed, but test memory and maximum canvas dimensions because pixel count rises quickly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can an image contain selectable text?

No. PNG, JPEG and WebP are raster images. Use a PDF or retain the original HTML when users need selectable, searchable text.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.