You can convert an HTML element to a JPEG for free in the browser with html2canvas and the Canvas API. The library renders DOM content into a canvas; canvas.toBlob() then encodes it as a JPEG you can download. This works without a paid service, but it reconstructs the page from the DOM rather than capturing the browser compositor, so the result may differ from what you see on screen.
Convert an HTML element to JPEG in the browser
This example captures the element with the ID capture, gives the canvas a white background, renders at the device pixel ratio, and downloads a JPEG at quality 0.9. Install the package with npm install @html2canvas/html2canvas in a project that supports browser-side JavaScript modules.
import html2canvas from "@html2canvas/html2canvas";
const element = document.querySelector("#capture");
if (!element) {
throw new Error('Could not find an element matching "#capture"');
}
const canvas = await html2canvas(element, {
backgroundColor: "#ffffff",
scale: window.devicePixelRatio
});
const blob = await new Promise((resolve) => {
canvas.toBlob(resolve, "image/jpeg", 0.9);
});
if (!blob) {
throw new Error("The browser could not encode the canvas as a JPEG");
}
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.download = "capture.jpg";
link.href = url;
link.click();
// Keep the object URL alive briefly so the browser can start the download.
setTimeout(() => URL.revokeObjectURL(url), 1000);
Put the code in a function you call after the page and target element are ready. For a page that uses a module script, for example, load the file with <script type="module" src="./capture.js"></script>. The target should be part of the current document; this method is not a general-purpose way to read and export another site’s page from your browser.
Why use toBlob()?
toBlob() creates a binary image object that can be downloaded through an object URL. It avoids building a large base64-encoded data URL in memory, making it the better default for large captures. The callback can receive null if the browser cannot create the requested image, which is why the example checks the result.
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 minutePC 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 & 11#1 Best Overall
- User-Friendly Portable Photo Printer for iPhone, Android & PC - Get beautiful and colourful memories with Liene 4x6 photo printer! After opening the entire package, you can find one cartridge + 20 sheets of photo paper (placed inside the machine packaging), as well as an additional box containing 80 sheets of photo paper (which includes two cartridges + 80 sheets of photo paper). Full package includes smartphone photo printer, Liene 4x6 photo printer papers (100 sheets), 3 colour cartridges, and fully sealed cassette to prevent dust. Minimalist and magnetic design for compact storage.
- Superior Quality 4x6 Photo Printer - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Clean the print head promptly if smudges are observed on printed photos during operation. Get Liene photo printers now for yourself and your loved ones, print your happy moments together and keep your love forever!
- Wi-Fi Photo Printer for Smartphone - The built-in hotspot of the photo printer makes it easy to print pictures from your phone, avoiding outside interference with a fast and stable connection. No other networks required! Simply connect your device to the independent instant photo printer 4x6 hotspot.
- Multiple Device Compatibility - Liene phone printer provides instant photo printing for up to 5 simultaneous connections. Share with family and friends or print from your different devices. No additional cables or Bluetooth required when printing photos with this picture printer. Note: Ensure the ink cartridge clicks into place before printing.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Square border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this photo printer for iphone 4x6 prints.
canvas.toDataURL("image/jpeg", 0.9) is a simpler alternative for small images or when a data URL is specifically needed. It returns the encoded image as a string, which can become memory-intensive for large canvases. Both export methods accept a JPEG quality value from 0 to 1.
Choose the area, resolution, and JPEG quality
Capture a region or the whole element
By default, html2canvas(element) renders the selected element. Its options also support region cropping with x, y, width, and height. Use these when you need a specific area of the rendered content rather than the full element. The selected dimensions are in CSS pixels; ensure the crop stays within the area you intend to render.
Set the output scale
The scale option controls the pixel density of the rendered canvas. Setting it to window.devicePixelRatio typically produces a sharper image on high-density displays, but also creates a larger canvas and file. If memory use or download size matters more than sharpness, use a lower fixed scale; if the capture is too soft, increase it and check that the resulting file remains manageable.
Rank #2
- Dock Photo Printer: The KODAK Dock Plus is a home photo printer that produces high-quality 4x6” prints directly from compatible smartphones. Featuring an integrated docking station, users can place their phone on the printer for better connection while simultaneously charging the device during printing.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Dock Plus is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Home Printing Station: Designed for stable desktop use, this dock photo printer connects to a power outlet for consistent performance and larger 4x6” prints. Ideal for home printing, photo albums, framing, family events, and everyday picture printing.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
Pick a background and format
JPEG does not preserve transparency. A white backgroundColor gives transparent areas a predictable appearance; choose another solid color if it suits the design. JPEG is lossy, so fine text and sharp edges can show ringing or other compression artifacts. Raising quality can reduce those artifacts at the cost of a larger file. If exact text edges matter more than file size, export PNG instead; PNG is the required fallback format for Canvas export support.
Recommended Free Tools
For formats that support resolution metadata, MDN documents 96 dpi metadata. That metadata is distinct from the canvas’s pixel dimensions: changing the scale changes how many pixels are rendered, while metadata alone does not add detail.
Make the capture more reliable
Wait for the content you need
Call the capture after the target exists and its content has been laid out. If images or other page content load asynchronously, wait for the relevant content before calling html2canvas; otherwise the captured DOM may not yet contain the final state. Keep the capture limited to the element and content you actually need to reduce avoidable rendering and memory work.
Rank #3
- 2x3" Portable Photo Printer: The upgraded PP01 photo printer uses advanced inkjet technology. This portable photo printer produces vivid, full-color prints on premium sticky-backed photo paper that is smudge-proof, water-resistant, and tear-resistant. The Nelko mini photo printer is pocket-sized and weighs only 308g, making it ultra-portable for school, travel, and field trips. Each ink cartridge prints up to 80 full-color 2x3 photos on sticky-backed paper
- Easy Printing via Bluetooth: The PP01 mini photo printer is compatible with iOS and Android phones via Bluetooth. Simply download the Nelko app from Google Play or the App Store. Load the 2x3 photo paper with the smooth side facing down. Install the ink cartridge, connect via Bluetooth, and print directly using the Nelko app. A USB charging cable is included; the adapter is not included
- High Photo Quality: This mini photo printer uses advanced inkjet technology for clear, vibrant prints. This portable photo printer produces 600 DPI high-resolution images with precise colors, capturing fine details and realistic tones. Each photo comes with adhesive backing, perfect for scrapbooks and preserving your memories. Personalize every photo for holidays, birthdays, or daily events
- Powerful App: The Nelko 2x3" PP01 photo printer app lets you edit photos and offers a variety of frame designs, making it perfect for personalizing your photos for projects like scrapbooking or journaling. Download the Nelko app to create collages and customize photos with filters, graffiti, borders, stickers, text, AI image editing, and many other features. Edit photos on your phone, then send them to the Nelko app for instant printing in under 90 seconds
- Versatile Usage Scenarios: This portable photo printer is ideal for travel journals, party favors, and family gatherings. Students use it for planners and photo printing. Crafters use it for DIY projects, custom labels, and scrapbooking. It's a practical tool for bloggers, small businesses, and event photographers to create instant giveaways. Perfect for Mother's Day surprises and heartfelt moments with loved ones using Nelko sticky-backed photo paper.
Omit controls and other unwanted elements
Add the data-html2canvas-ignore attribute to elements that should not appear in the capture, such as a temporary control or close button:
<button data-html2canvas-ignore>Close</button>
This is useful when the source page is yours or you can edit its markup. For elements you cannot mark up, consider changing the capture target or preparing a dedicated view for export.
Handle images from other origins
Images served from another origin can taint the canvas. Once tainted, browser security rules prevent reading or exporting its pixels. The useCORS option can request eligible cross-origin images through CORS, but it does not override the image server’s policy: the server must permit the request. If you control that server, configure suitable CORS headers. Otherwise, omit the image, use an authorized same-origin copy, or use a proxy you are permitted to use. Do not assume a successful-looking render means the canvas will be exportable.
Rank #4
- Dual 4x6" & 3x3" Photo Printer Paper Tray Convenience: Seamlessly print both 6-inch standard photo paper and 3-inch sticky-backed paper with our innovative dual tray design. This compact phone photo printer for smartphone offers easy storage and quick access, making it perfect for diverse printing needs without taking up much space. Enjoy vibrant, high-quality prints every time.
- Fast Bluetooth Connectivity: Experience lightning-fast printing with our liene photo printer's Bluetooth connection, which pairs in just 13 seconds. Enjoy a seamless and efficient printing experience, perfect for capturing and sharing memories on the go without the hassle of cables or complex setups.
- Superior Quality Photo Printer 4x6 - Print photos like no other thanks to the thermal-dye sublimation tech adopted by the picture printer for iphone. The dyes deeply penetrate the paper for vibrant photo printing, and the laminated surface is resistant to water, scratches, fingerprints and fading. Get Liene photo printers now as amazing gifts for yourself and your loved ones, print your happy moments together and keep your love forever!
- Multiple Device Compatibility - Liene picture printer for iphone provides instant photo printing for up to mutiple simultaneous connections. Share with family and friends or print from your different devices. No additional cables required when printing photos with this phone printer.
- Customize your Printing with the Liene App - Customize your photos with our specialized App! You can add a Polaroid border, insert filters, enhance the contrast and brightness, check printing status, and more. You can even print your ID and Visa photos from home with this iphone photo printer for 4x6 & 3x3 prints.
Understand what the library does not capture exactly
html2canvas builds an image from the DOM and the CSS features it supports; it is not a pixel-for-pixel screenshot of the browser’s compositor. Its project documentation cautions that “The screenshot is based on the DOM and as such may not be 100% accurate to the real representation.” Unsupported CSS, plugin content, and cross-origin iframes may be missing or rendered differently. If exact browser output is essential, compare the generated JPEG with the live page and use a browser-based screenshot method instead.
Troubleshoot common export problems
- The capture is blank or missing content: confirm the selector matches an element, invoke capture after the element is populated, and check whether the missing feature is outside html2canvas’s supported rendering or inside a cross-origin iframe.
- Export throws a security error or the image cannot be read: look for images from another origin. Enable
useCORSfor eligible images and confirm the image host grants CORS access; otherwise remove or replace the image or use an authorized proxy. - The download does not start: check that
toBlob()returned a blob, that the link has a filename and object URL, and that the code runs in a browser after the target is available. Keep the object URL alive until the browser has started the download. - The JPEG has a solid background where transparency was expected: this is normal for JPEG. Use a deliberate background color or export PNG for transparency.
- Text looks soft or has artifacts: increase
scalefor more rendered pixels or raise JPEG quality. For lossless, crisp text, choose PNG rather than JPEG. - The page becomes slow or runs out of memory: reduce the capture area or scale and prefer
toBlob()overtoDataURL(), which creates a large encoded string. - The output differs from the visible page: check unsupported CSS, dynamic content that had not loaded, embedded plugin content, and frames or images blocked by cross-origin rules. html2canvas is a DOM reconstruction, not a compositor screenshot.
When a hosted screenshot API is a better fit
The browser method is free and keeps the rendering on the device running the page, but it depends on that page’s browser context and security permissions. A hosted browser API is useful when you need repeatable captures of public URLs, scheduled or batch jobs, or server-side automation without running capture code inside your own page. It requires sending the URL and relevant request data to a service, and its credentials, limits, and pricing need to be considered. For your own page or sensitive content, assess what the service receives before sending it.
For a hosted API, ScreenshotNeo is an option for a one-request capture, with cookie banners, popups, and chat widgets removed before the shot, and billing based on page verdicts so bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. Details and parameters are in the ScreenshotNeo API documentation.
Or skip the browser setup
For a public webpage, send one GET request to ScreenshotNeo and save the response as an image. Replace the example URL with the page you want to capture and use your API key. The API can return PNG, JPEG, WebP, or PDF; the example below requests a JPEG file by setting the output format.
Best Value
- Instant Photo Printing: The KODAK Mini 2 Retro is a portable photo printer designed to turn smartphone pictures into high quality prints in seconds. Whether capturing family moments, travel highlights, journaling pages, or creative projects, this mini printer lets you print real photos anytime, anywhere.
- Genuine 4PASS dye sublimation printing: Each photo is produced in three color layers and finished with a clear protective lamination layer. In approximately 55 seconds, you receive a smooth, detailed print designed to resist fingerprints, water, and fading for long-lasting quality.
- Easy to Use: Print photos quickly without complicated setup or technical steps. Simply power on, connect wireless bluetooth, and start printing within seconds. The Mini 2 Retro is built for straightforward operation, making it ideal for first time users and everyday photo printing.
- Print Anytime, Anywhere: Small enough to fit in your hand, bag, or even a pocket, the Mini 2 Retro is built for on-the-go printing. Ideal for parties, trips, school projects, scrapbooks, and spontaneous moments where you want real prints without waiting.
- KODAK Photo Printer APP: Featuring integrated Bluetooth connectivity, this portable printer connects to compatible iOS and Android devices through the KODAK Photo Printer app. Edit, crop, and customize your photos before printing for creative results.
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://stripe.com
-d format=jpeg
-o shot.jpg
ScreenshotNeo accepts and removes cookie/consent banners, newsletter popups, and chat widgets before the capture; those cleanup steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. See ScreenshotNeo for the service and the API documentation for request options.
Sign up for ScreenshotNeo: get 1,000 screenshots a month free with no card.
Frequently asked questions
Can I convert a div to JPEG with JavaScript?
Yes. Select the div, render it with html2canvas, and export the resulting canvas as JPEG with toBlob() or toDataURL().
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsCan I convert a webpage I do not own?
A browser page generally cannot read another origin’s content freely because of browser security rules. For a public URL capture, use a hosted browser service rather than trying to extract cross-origin page content from your own page.
Is the conversion truly free?
The html2canvas and Canvas workflow described here runs in the browser and does not require a paid screenshot API. Your hosting, development environment, and any proxy or hosted service you separately choose may have their own costs.
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.




