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

To export HTML to JPG, render it in a browser and encode the result as JPEG. For an element in a web page, use html2canvas and download the canvas with toDataURL('image/jpeg', quality). For a full web page or server-side automation, use Puppeteer with headless Chromium and save a JPEG screenshot. Choose the browser-side method for a quick in-app export; choose a real browser for repeatable captures, cross-origin content, or scheduled jobs.

Choose the right way to convert HTML to JPG

The best method depends on where the HTML runs and what needs to appear in the image. A browser-side library can export an element from an open page. A browser automation tool can load a URL or HTML document and capture the rendered page. PHP applications can call Puppeteer through Browsershot.

Need Use Important qualification
Export a component or element from the current web app html2canvas It reconstructs the DOM and supported styles; it is not a guaranteed pixel-perfect browser screenshot.
Capture a full page, a URL, or HTML on a server Puppeteer with Chromium Wait for content and set the viewport deliberately before capture.
Call image capture from a PHP or Laravel application Spatie Browsershot It provides a PHP interface to Puppeteer; the browser runtime is still required.
Capture a remote URL without managing browser setup ScreenshotNeo A screenshot API returns the image from one HTTP request; the example below uses its JPEG output option.

Export an element in the browser with html2canvas

html2canvas converts a DOM element into a canvas in the current browser page. It is useful when an export button belongs in the web app and the element is already rendered. Install it using your project’s package manager, then call it after the target element is present.

import html2canvas from '@html2canvas/html2canvas';

const element = document.querySelector('#capture');
if (!element) throw new Error('Capture element #capture was not found');

const canvas = await html2canvas(element, {
  scale: window.devicePixelRatio,
  useCORS: true
});

const link = document.createElement('a');
link.download = 'page.jpg';
link.href = canvas.toDataURL('image/jpeg', 0.92);
link.click();

Give the element a stable selector, for example <main id="capture">...</main>. The returned canvas is encoded as JPEG at quality 0.92 in this example. JPEG quality ranges from 0 to 1; lowering it usually reduces file size at the cost of visible compression artifacts. JPEG does not preserve transparency, so transparent canvas areas are not suitable if the exported image must retain an alpha channel.

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.

Control what is captured

The export reflects the element’s rendered DOM state when the call runs. Put the UI into the state you want first: expand content, apply the desired theme, and ensure any loading indicators or transient controls are gone. html2canvas also supports options for scale, cropping, CORS handling, and ignoring selected elements; consult its official examples for the exact option syntax for your installed version.

Use scale to influence output resolution. A higher scale creates more pixels and can improve sharpness, but it also increases memory use and output size. Device pixel ratio is convenient for a display-aware export, though it may produce unexpectedly large files on high-density screens; set a fixed scale if consistent dimensions matter.

Know the fidelity and browser-security limits

html2canvas is a DOM reconstruction tool, not a browser’s native screenshot facility. Its documentation cautions that the result may not be fully accurate to the page’s real representation because it rebuilds the image from information available in the DOM. Unsupported or differently implemented CSS can appear wrong.

Cross-origin images are a common failure point. The image server must permit CORS access for canvas use; useCORS: true requests CORS loading but cannot override the remote server’s policy. If you control the source, configure suitable CORS response headers. Otherwise, a server-side same-origin proxy may be appropriate. Cross-origin iframes cannot be rendered by html2canvas because browser security prevents access to their contents.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

Very large documents can exceed browser canvas dimension or memory limits, resulting in blank or partial output. The html2canvas documentation describes these limitations; for large full pages, use a real browser capture and test the expected dimensions on the target runtime.

Capture a URL or HTML document with Puppeteer

Puppeteer’s Page API controls a real Chromium page, making it a better fit for server-side jobs, exact browser layout, and full-page URL captures. Install Puppeteer in a Node.js project with npm install puppeteer. The following ES module loads a page, waits for network activity to settle, sets a viewport, and writes a full-page JPEG.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({
    width: 1440,
    height: 900,
    deviceScaleFactor: 1
  });
  await page.goto('https://example.com', { waitUntil: 'networkidle0' });
  await page.screenshot({
    path: 'page.jpg',
    type: 'jpeg',
    quality: 92,
    fullPage: true
  });
} finally {
  await browser.close();
}

Run it in a project configured for ES modules, or adapt the imports to that project’s module system. Replace the example URL with the page to capture. fullPage: true captures beyond the current viewport; omit it when the desired output should be only the visible viewport. Puppeteer documents navigation and screenshot controls in its Page API.

Render supplied HTML instead of navigating to a URL

Puppeteer can also set page content directly. This lets a server generate markup and render it through Chromium rather than trying to convert HTML source text directly into pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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><meta charset="utf-8"><title>Export</title></head>
<body><main><h1>Monthly report</h1><p>Rendered in Chromium.</p></main></body>
</html>`;

await page.setContent(html, { waitUntil: 'networkidle0' });
await page.screenshot({
  path: 'report.jpg',
  type: 'jpeg',
  quality: 92,
  fullPage: true
});

For remote fonts, images, or scripts referenced by that HTML, wait until they are available before taking the screenshot. A network-idle condition is not a universal guarantee that every application has finished rendering: pages that continuously poll, lazy-load on scroll, or update after a timer may need an explicit selector wait or application-specific readiness signal.

Make dimensions and page state intentional

Set viewport width and height before navigation when the layout depends on responsive breakpoints. The width determines which responsive arrangement is rendered; height affects the visible viewport, while full-page capture expands beyond it. Choose deviceScaleFactor deliberately because it changes the pixel density of the output.

Before capture, wait for web fonts and important images if they affect layout or appearance. For dynamic pages, wait for a meaningful selector or a known application-ready signal rather than relying only on a fixed sleep. If a page has lazy-loaded images, scroll through the relevant content or otherwise trigger loading before capturing the full page.

Use Browsershot from PHP or Laravel

Spatie Browsershot provides a PHP interface for taking screenshots through Puppeteer and supports a URL or arbitrary HTML as input. This is useful when the calling application is written in PHP, but it does not remove the need for a functioning Puppeteer/Chromium setup. Follow the installation and runtime requirements for the Browsershot version used by the project, then configure an image output path and JPEG format as documented by that version.

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

For Laravel, keep browser execution in an appropriate worker or server environment if image generation is time-consuming. Confirm that the PHP process can reach the browser executable and any remote assets referenced by the page. Those deployment details vary by operating system and hosting environment, so use the project’s installation guide rather than assuming a local development setup will behave the same in production.

Or skip the browser setup

For a remote webpage, ScreenshotNeo can return a screenshot through one GET request instead of requiring you to install and operate Chromium. Its clean-capture behavior accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents.

For JPEG output, use the format=jpeg parameter. See the ScreenshotNeo API documentation for supported parameters and behavior.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -d format=jpeg 
  -o page.jpg

Replace YOUR_API_KEY with your key and the example URL with the page to capture. ScreenshotNeo accepts the parameter names used by other screenshot APIs, which can simplify switching an existing integration. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Every feature is available on every plan. Learn about ScreenshotNeo, then sign up for 1,000 free screenshots a month with no card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common HTML-to-JPG problems

  • The html2canvas result is missing images: Check whether the images are cross-origin. Enable useCORS and confirm that the image host sends permissive CORS headers; otherwise use a same-origin proxy or a real-browser server capture.
  • An embedded frame is blank: html2canvas cannot read cross-origin iframe contents due to browser security. Capture the frame’s page separately where permitted, or use a workflow that can access the content under the applicable security rules.
  • Text, shadows, or layout differ from the page: html2canvas reconstructs supported styles rather than taking a native screenshot. Check its supported CSS behavior and, where browser fidelity matters, use Puppeteer or another real-browser automation tool.
  • The exported file is blank or cut off: For html2canvas, reduce the captured area or scale if canvas limits are exceeded. For Puppeteer, verify the page loaded, set the intended viewport, and ensure full-page capture is appropriate.
  • Fonts or images look unfinished: Wait for font and image loading or an application-ready selector before capturing. Network-idle alone may not cover every lazy-loaded or delayed element.
  • The output is unexpectedly large or soft: Check the capture scale, viewport, device scale factor, and JPEG quality. Higher pixel density and quality can increase file size; lower quality can create artifacts.
  • Puppeteer cannot launch in production: Confirm Chromium is installed or available through the Puppeteer installation used by the deployment, and that the service account can execute it. Compare the production runtime with the supported installation instructions for the version in use.

Choose JPEG only when its trade-offs fit

JPEG is lossy, so it is often suitable for photographic material or when a smaller file matters more than perfectly crisp edges. Text-heavy interfaces, diagrams, and sharp UI boundaries can show compression artifacts; PNG is often a better choice for those. If transparency matters, choose a format that preserves it rather than JPEG. Compare the actual exported image at its intended display size before settling on quality and dimensions.

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.

Frequently asked questions

Can I convert an HTML file to JPG without opening it in a browser?

Not by simply changing its extension: HTML describes content and layout, while JPG stores raster pixels. A renderer such as a browser must interpret the HTML and produce the image. Puppeteer is one way to automate that rendering on a server.

Can html2canvas capture a whole website?

It captures a DOM element supplied to it, which can be a large page container, but very large canvases can hit browser limits. For a full-page screenshot workflow, Puppeteer’s full-page screenshot option is generally more suitable.

Does JPEG quality 92 mean 92% visual accuracy?

No. The number is a quality setting for JPEG encoding, not a promise of a particular perceptual score or match to the source. The visible result depends on the content and encoder.

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

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.