Recommended Free Tools
For a quick, in-page export, use html2canvas to turn a selected DOM element into a downloadable PNG. It reconstructs an image from the page’s DOM and styles; it does not take a pixel-perfect screenshot of the browser. If you need the page as a real browser renders it, especially in a server workflow, use Playwright or Puppeteer to capture a browser screenshot instead.
Choose the right way to capture the page
The best method depends on where your code runs and how closely the result must match the displayed page. These approaches solve related but different problems:
| Need | Use | Important trade-off |
|---|---|---|
| Export an element from the page a user is viewing | html2canvas |
Convenient client-side canvas output, but it rebuilds a representation from DOM and CSS and may differ from the rendered page. |
| Capture a rendered page in a server workflow | Playwright or Puppeteer | Controls a real browser, but requires browser automation setup and browser resources. |
| Capture an element or full page in automation | Playwright | Its screenshot API supports both element screenshots and full-page capture. |
| Capture a browser tab in an extension | The browser’s native extension screenshot API | Use the browser capture API rather than trying to reconstruct a tab through html2canvas. |
For html2canvas, the project explicitly describes its output as a DOM-based representation rather than an actual screenshot. It only understands some CSS, so it is a good fit when a convenient client-side export matters more than exact pixel equivalence.
Convert an element to a PNG in the browser
1. Add html2canvas to your project
Install the package with npm:
npm install html2canvas
The following example assumes your app is bundled so it can resolve the package import. Put the content to export inside an element with the ID capture:
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
<section id="capture">
<h1>Monthly report</h1>
<p>This section will be exported as an image.</p>
</section>
<button id="save-image" type="button">Download PNG</button>
2. Render the selected element and trigger a download
Call html2canvas after the library and page elements are available. It returns a Promise that resolves to a canvas. Export that canvas as PNG data and use a temporary download link:
import html2canvas from 'html2canvas';
const button = document.querySelector('#save-image');
button.addEventListener('click', async () => {
const element = document.querySelector('#capture');
if (!element) throw new Error('Could not find #capture');
const canvas = await html2canvas(element);
const link = document.createElement('a');
link.download = 'webpage.png';
link.href = canvas.toDataURL('image/png');
link.click();
});
This captures the selected element, not automatically the entire document. Pick a wrapper that contains all the content you want in the output. For a user-selected region, html2canvas also documents crop coordinates; for a higher-resolution export, its examples show scaling the render, including by the device pixel ratio. More pixels can make a much larger canvas, so use higher scale only when the output needs it.
Adjust the capture when the default is not enough
Capture a region or increase resolution
Use html2canvas options when you need to control the canvas area or scale. For example, set x, y, width and height to define a crop, or set scale to increase output resolution. The crop coordinates are relative to the page’s capture context, so verify that the selected area includes the intended content. There is no universal safe maximum canvas size: browser and platform limits vary, and oversized canvases can be blank or partially rendered.
Rank #2
Let remote images load only when the server permits it
If the selected element contains images hosted on another origin, the browser’s content policy may prevent their pixel data from being read or exported. The documented html2canvas option useCORS: true can help only when the remote server sends the required CORS headers. A proxy is another documented route, but it must be trusted and configured carefully; neither option bypasses browser security policy.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteconst canvas = await html2canvas(element, {
useCORS: true
});
Do not assume this setting will make every third-party image appear. The image host must allow the request under its CORS policy, and the image still needs to load successfully.
Use a real browser for server-side screenshots
html2canvas depends on browser globals such as window, document and computed styles. It is client-side only; running it directly in Node.js is not a substitute for opening the page in a browser. For server-side work, automate Chromium or another supported browser with Playwright or Puppeteer and use its screenshot API.
Playwright example: capture a full page
Install Playwright and its browser before running the script:
npm install playwright
npx playwright install chromium
Save this as an ES module script, for example capture.mjs. It opens the target URL, waits for the page load event, and writes a full-page PNG:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsimport { chromium } from 'playwright';
const url = process.argv[2] ?? 'https://example.com';
const browser = await chromium.launch({ headless: true });
try {
const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
await page.goto(url, { waitUntil: 'load', timeout: 30000 });
await page.screenshot({ path: 'webpage.png', fullPage: true });
} finally {
await browser.close();
}
Run it with node capture.mjs https://example.com. For a particular element instead of the whole page, locate it and call its screenshot method:
Rank #4
const target = page.locator('#capture');
await target.screenshot({ path: 'element.png' });
The full-page option captures beyond the current viewport. It does not guarantee that every site has finished loading all dynamic content. If the page renders important content after initial load, wait for a meaningful selector or other site-specific readiness condition before taking the screenshot.
Puppeteer alternative
Puppeteer also controls a browser and provides a page screenshot API. Use it when it fits your existing automation stack; for element and full-page screenshot examples, Playwright’s documented API is a direct option. The important distinction from html2canvas is the execution model: browser automation captures rendered browser output, while html2canvas reconstructs from DOM information.
Handle common failures
The PNG differs from what I see on screen
- Cause: html2canvas supports only a subset of CSS and reconstructs the page rather than capturing rendered pixels.
- Fix: Check whether the affected style is supported, simplify the target markup if practical, or switch to Playwright or Puppeteer when rendered-browser fidelity is the priority.
Images are missing or exporting throws a security error
- Cause: A cross-origin image may not allow access to its pixel data under browser content policy.
- Fix: If you control the image server, configure the required CORS headers and try
useCORS: true. Otherwise, use a carefully controlled proxy or omit the inaccessible asset. Do not treat client-side code as a way around CORS.
Content inside an iframe is absent
- Cause: A page can access and render same-origin frames recursively, but browser security restrictions prevent access to cross-origin frames. A sandboxed frame without
allow-same-originhas the same limitation. - Fix: Capture the frame from a context that can access it, if available, or use browser automation to navigate and capture the relevant page. Do not expect page JavaScript to inspect an unrelated origin’s frame.
The output is blank or only partly drawn
- Cause: The canvas may be too large for the current browser and platform, or parts of the page may not have loaded when capture begins. Canvas limits vary; there is no single safe maximum that applies everywhere.
- Fix: Capture a smaller element or crop, lower the scale, and wait for required images or page content before rendering. If a very tall page is the issue, use browser automation and test the capture in the target environment.
The code fails in Node.js
- Cause: html2canvas expects browser APIs such as
windowanddocument. - Fix: Run html2canvas in the page itself, or use Playwright or Puppeteer for a server-side browser capture.
I am building a browser extension
- Cause: A page-level DOM renderer is not the most reliable way to capture a browser tab.
- Fix: Use the extension’s native screenshot API. The html2canvas FAQ specifically points extension developers to native capture APIs such as
captureVisibleTab().
Or skip the browser setup
If you want an image from a URL without writing browser automation, ScreenshotNeo is a screenshot API and MCP server. Its one-request endpoint can return PNG, JPEG, WebP or PDF. Here is a cURL request that saves a WebP screenshot:
Best Value
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Replace YOUR_API_KEY with your key and change the URL to the page you need. See the ScreenshotNeo documentation for request parameters and response details. Cookie banners, popups and chat widgets are removed before the shot; bot checks, blank pages and failed loads are never billed. An MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
Choose based on fidelity, environment and output
Use html2canvas when a user should export a chosen part of the current page without sending the task to a server, and your content works with its supported CSS and resource access. Use Playwright or Puppeteer when the capture belongs in a server workflow or must reflect browser rendering. For extensions, prefer native tab-capture APIs. In every case, test the actual page, output dimensions and image permissions in the environment where the code will run.
Frequently Asked Questions
Can html2canvas convert a webpage to JPEG or WebP?
The documented download pattern here exports PNG with toDataURL('image/png'). Canvas export supports other formats where the browser implements them, but confirm the desired format and quality handling in your target browser.
Can a website capture content from a cross-origin iframe?
Not through ordinary page JavaScript when browser same-origin restrictions prevent access. A browser screenshot can capture the rendered viewport, but direct inspection of the other origin’s frame remains restricted.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
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.

