To export an HTML element as a JPG in a web app, render it with html2canvas, then convert its canvas to JPEG with canvas.toDataURL('image/jpeg', quality). For a full webpage, cross-origin content, or repeatable server-side jobs, use a real browser such as Puppeteer with Chromium and save the screenshot as JPEG. The right method depends on whether you need a convenient DOM export or a capture of what a browser actually renders.
Choose the right HTML-to-JPG method
| Need | Suitable method | Important limitation |
|---|---|---|
| Export one element from a browser-based app | html2canvas | Reconstructs the DOM; it may not match the browser rendering exactly. |
| Capture a URL or arbitrary HTML on a server | Puppeteer with headless Chromium | Requires a browser runtime and careful handling of page readiness. |
| Use PHP or Laravel | Spatie Browsershot | Uses Puppeteer underneath, so the server still needs its browser dependencies. |
| Automate captures without managing a browser | ScreenshotNeo | Requires an API key and a network request. |
JPEG is a lossy format. It is often a reasonable choice for photographic content or when a smaller image matters more than perfectly crisp edges. For text-heavy UI, diagrams, or transparency, PNG is usually a better fit: JPEG does not preserve transparency and can soften sharp boundaries.
Export an HTML element in the browser with html2canvas
Use this approach when the page is already open in a browser and you want to let a user download a specific DOM element. The official html2canvas examples demonstrate element capture, scaling, CORS configuration, cropping, and excluding elements. It creates a canvas from DOM and style information rather than taking a native browser screenshot, so treat the result as a rendered reconstruction.
Install the package
In a project with npm, install the package:
npm install html2canvas
Make sure the selected element exists and has loaded any content you want included. The following example uses the module import shown in the html2canvas examples.
Crashes, 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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Runnable browser example
import html2canvas from '@html2canvas/html2canvas';
const element = document.querySelector('#capture');
if (!element) {
throw new Error('No element found for #capture');
}
const canvas = await html2canvas(element, {
scale: window.devicePixelRatio,
useCORS: true
});
const link = document.createElement('a');
link.download = 'element.jpg';
link.href = canvas.toDataURL('image/jpeg', 0.92);
link.click();
Place the code in a module script or your app’s module entry point. The scale option uses the display’s device-pixel ratio to produce a higher-resolution canvas on high-density screens; it also increases memory use. The quality argument to toDataURL is a value from 0 to 1 for JPEG encoding. The example uses 0.92 as a chosen export setting, not a universal quality optimum.
Control what is captured
- Capture one element: pass the element itself to
html2canvas, rather than the full document. - Exclude controls: use the library’s ignore mechanism or temporarily hide export-only elements before rendering.
- Crop: use the library’s supported crop or rendering options when only part of the selected element is needed. Check the library documentation for the option names supported by the installed version.
- Set a deliberate scale: a larger scale can improve output detail, but can also make the canvas much larger and more likely to exceed browser limits.
Do not assume every CSS feature or browser effect will be reconstructed faithfully. html2canvas’s documentation explicitly warns that the result is based on available DOM information and may not be 100% accurate to the real page representation.
Handle cross-origin images and frames
Images loaded from another origin can taint a canvas. Once that happens, browser security prevents exporting its pixels through toDataURL. Setting useCORS: true asks the renderer to use CORS for eligible images; it does not override the image server’s policy. The remote server must send suitable CORS headers, or you need to serve the asset from your own origin through a permitted proxy.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Cross-origin iframes are a separate restriction: browser security prevents html2canvas from reading their contents. If the frame is under your control, a same-origin setup may avoid that boundary; otherwise, use a browser-based capture strategy that can access the target page as a top-level navigation, subject to the site’s access controls.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Capture a webpage or HTML on the server with Puppeteer
When the target is a URL, you need repeatable automation, or the output should reflect Chromium’s browser rendering, use Puppeteer. Its Page API provides navigation, content-loading, viewport, and screenshot controls. The example below saves a full-page JPEG from a URL.
Install and run
In a Node.js project, install Puppeteer:
npm install puppeteer
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();
}
The viewport establishes the page’s layout width and height; deviceScaleFactor controls the pixel density. fullPage: true asks Puppeteer to capture the full page rather than just the viewport. The selected JPEG quality is an encoding choice. Change the viewport to match the intended output; a different width can change responsive layout and line wrapping.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Capture supplied HTML instead of a URL
For markup you already have, load it into the page with setContent before calling screenshot:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setViewport({ width: 1200, height: 800 });
await page.setContent(`
<!doctype html>
<html>
<head><meta charset="utf-8"><title>Export</title></head>
<body><main><h1>Rendered HTML</h1><p>Saved as JPEG.</p></main></body>
</html>
`, { waitUntil: 'networkidle0' });
await page.screenshot({ path: 'html.jpg', type: 'jpeg', quality: 92 });
} finally {
await browser.close();
}
For externally hosted images, fonts, stylesheets, or scripts, ensure the page can reach those resources and wait until they are ready. For dynamic pages, a network-idle condition is not always sufficient: a page may continue changing after network requests settle, or keep connections open. In that case, wait for a selector that indicates the desired content is ready, or wait for the relevant assets and application state explicitly before capturing.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Make full-page captures predictable
- Fix the viewport dimensions so responsive breakpoints do not vary between runs.
- Wait for the content to appear and for web fonts and images to finish loading before the screenshot.
- For lazy-loaded images, scroll through the page or otherwise trigger loading before capturing.
- Check long documents at their actual output size; extremely large page dimensions can stress browser memory and image limits.
- Close the browser in a
finallyblock so an error during navigation or capture does not leave the process running.
Use Browsershot from PHP or Laravel
Spatie Browsershot provides a PHP interface for saving an image from a URL or arbitrary HTML, using Puppeteer to drive the browser. It is a practical fit when the application is already PHP-based and you want to initiate captures in that codebase. Because it relies on Puppeteer, it is not a browser-free server solution: deploy the required Node.js and browser components and follow the installation requirements for the Browsershot version you use.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Or skip the browser setup
If you would rather call a screenshot service than install and operate Chromium, ScreenshotNeo accepts a URL and can return a JPG, PNG, WebP, or PDF. The following is a one-request example; see the ScreenshotNeo API documentation for the available parameters and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.jpg
ScreenshotNeo can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers screenshot and page-information tools for AI agents and MCP clients. The free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots. All features are available on every plan.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card required.
Troubleshoot common export problems
The JPG is blank or only partly rendered
- Likely cause: the page has not finished loading, content is lazy-loaded, or the canvas/browser reached a dimension limit.
- Fix: wait for a visible target selector and required images or fonts; trigger lazy loading before capture; reduce the viewport, page size, or html2canvas scale and retry.
Export fails with a tainted-canvas security error
- Likely cause: an image from a different origin was loaded without permission for canvas use.
- Fix: configure the image host to return suitable CORS headers, serve the image from the same origin, or use a permitted proxy.
useCORS: truealone cannot grant access.
An iframe is missing from the html2canvas output
- Likely cause: it is cross-origin and the browser does not allow the parent page to inspect its contents.
- Fix: capture a same-origin frame if you control it, or navigate a real browser directly to the page that must be captured.
The output does not match the visible browser page
- Likely cause: html2canvas reconstructs supported styles from the DOM rather than photographing the rendered screen; some CSS or page behavior may not be reproduced.
- Fix: use Puppeteer or another real-browser automation approach when browser rendering fidelity matters, then check the viewport, readiness timing, and loaded assets.
The server capture times out or hangs
- Likely cause: the page never reaches the selected network-idle condition, or required content is blocked or slow.
- Fix: use an appropriate navigation readiness condition and wait for the specific content you need. Inspect the page’s network and access behavior, and ensure the server can reach its resources.
Performance, reliability, and file-size trade-offs
Browser-side export avoids a server capture service and is convenient when the user already has the page open, but large canvases consume substantial memory. Increasing html2canvas scale raises pixel dimensions in both directions, so memory demand can grow quickly. The library documents blank or partial output when canvas limits are exceeded; test representative long pages and reduce scale or capture smaller regions if needed.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Puppeteer gives you control over a real browser, but each capture depends on launching or reusing a browser, navigating successfully, and waiting for the content state you actually need. For batch or scheduled work, manage browser lifecycle and concurrency deliberately, and test failures as well as successful pages. JPEG quality is also a trade-off: lowering it may reduce file size but adds compression artifacts, especially around text and interface edges. Compare the exported result at its intended display size rather than choosing a quality value by habit.
Quick decision checklist
- Choose html2canvas for a client-side export of a selected element whose DOM can be read by the current page.
- Choose Puppeteer for URL or HTML capture where real browser rendering, repeatable automation, or full-page output matters.
- Choose Browsershot when the calling application is PHP/Laravel and a Puppeteer-backed capture fits the deployment.
- Use PNG instead of JPG when transparency or crisp UI/text is more important than JPEG’s smaller photographic output.
- For every approach, make viewport, content readiness, cross-origin assets, and image dimensions explicit.
Frequently Asked Questions
Can I convert HTML to JPG with CSS alone?
CSS can style content but does not itself provide a standard browser feature for exporting the rendered DOM as a downloadable JPEG. Use a canvas-based library or browser screenshot tool.
Can html2canvas capture a page without JavaScript?
No. html2canvas runs in the browser and relies on the DOM and computed styles, so server-side generation needs a browser automation tool or service.
Can I use this for a webpage I do not own?
A browser can only capture pages it can access under applicable browser and site restrictions. Do not bypass authentication, access controls, or a site’s terms.
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.




