Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteUse node-html-to-image when you have an HTML string on the server: install it with npm, set type: 'jpeg', define stable CSS dimensions, and either write the result to a file or use the returned Buffer. The package drives Puppeteer, so Chromium is required. If you already have a rendered DOM in a browser, the client-side html-to-image package is a better fit. For maximum browser control, use Puppeteer directly.
Choose the conversion method
| Input and requirement | Best option | Why |
|---|---|---|
| HTML string in Node.js; simple file or buffer output | node-html-to-image |
Small API around Puppeteer with JPEG type, quality, selector, waiting and page hooks. |
| HTML string; precise browser lifecycle, viewport, network or request control | Puppeteer | Direct access to Chromium, navigation, viewport, interception and element screenshots. |
| An element that already exists in a browser DOM | html-to-image |
Runs in the browser and returns a JPEG data URL without a server-side Chromium process. |
Server-side conversion with node-html-to-image
1. Create a project and install the package
mkdir html-to-jpg
cd html-to-jpg
npm init -y
npm install node-html-to-image
The package uses Puppeteer to render HTML, so installation may download a compatible Chromium build. In containers or serverless environments, plan for a Puppeteer-compatible browser binary and its system libraries.
2. Render a complete HTML document to a JPG file
const nodeHtmlToImage = require('node-html-to-image');
(async () => {
await nodeHtmlToImage({
output: './image.jpg',
type: 'jpeg',
quality: 85,
html: `<!doctype html>
<html>
<head>
<style>
body { margin: 0; width: 1200px; height: 630px; }
</style>
</head>
<body><h1>Hello from HTML</h1></body>
</html>`
});
})();
type: 'jpeg' is essential: the default output is PNG. The quality value controls JPEG compression, and output is the destination path. CSS dimensions establish the rendered size; set them explicitly when you need reproducible social cards, invoices or thumbnails.
3. Keep the JPEG in memory
const nodeHtmlToImage = require('node-html-to-image');
(async () => {
const imageBuffer = await nodeHtmlToImage({
type: 'jpeg',
quality: 85,
html: '<html><body><div>Render me</div></body></html>'
});
// Send imageBuffer from an HTTP response, store it in object storage,
// or attach it to another API request.
})();
Omit output to receive a Node.js Buffer. For an HTTP endpoint, send it with Content-Type: image/jpeg; do not convert it to a UTF-8 string.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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.
4. Capture one element instead of the whole body
const nodeHtmlToImage = require('node-html-to-image');
(async () => {
await nodeHtmlToImage({
output: './card.jpg',
type: 'jpeg',
selector: '#card',
html: `<html><body>
<section id="card" style="width: 900px; padding: 40px;">
<h1>Invoice preview</h1>
</section>
</body></html>`
});
})();
Without selector, the package captures the body. A selector is preferable for a card, receipt or other component because unrelated page content is excluded. Make sure the selector exists; a typo or element created later in JavaScript can produce an empty or failed capture.
Make rendering deterministic
Set dimensions in CSS
For node-html-to-image, define width and height on the body or target element. Include box-sizing, remove default margins, and avoid layout that depends on an unconstrained viewport:
* { box-sizing: border-box; }
html, body { margin: 0; }
body { width: 1200px; height: 630px; overflow: hidden; }
If content can exceed the fixed height, decide whether to increase the canvas, allow scrolling, or capture a specific element whose dimensions are known.
Wait for fonts, images and application code
Use the package’s documented waitUntil setting and its page hook when external resources or client-side rendering must finish before the screenshot. Ensure image URLs, web fonts and APIs are reachable from the machine running Chromium. A page that appears complete in a local browser can still capture before a remote font or image has loaded.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 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.
Control the JPEG trade-off
JPEG is smaller than a lossless image but introduces artifacts around text and sharp edges. Raise quality for readable typography and lower it for smaller transfers. If transparency or pixel-perfect text is required, JPEG is the wrong format; use PNG instead. JPEG has no transparent background, so set an explicit background color in your HTML.
Use Puppeteer directly for full control
The lower-level route makes browser lifecycle, viewport and navigation explicit. Install Puppeteer:
npm install puppeteer
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setViewport({ width: 1200, height: 630, deviceScaleFactor: 1 });
await page.setContent(`<!doctype html>
<html><body style="margin:0"><h1>Hello</h1></body></html>`, {
waitUntil: 'load'
});
await page.screenshot({
path: './image.jpg',
type: 'jpeg',
quality: 85,
fullPage: true
});
} finally {
await browser.close();
}
})();
Use page.goto(url, options) for a real URL, page.setContent for an HTML string, and page.screenshot for the output. Puppeteer is the better choice when you need custom headers, cookies, request interception, a particular viewport, explicit font handling, or a screenshot of a located element rather than the full page. For an element, locate it and call its screenshot method after the page is ready.
Convert an existing browser DOM with html-to-image
html-to-image is a browser-side alternative. It accepts an existing DOM node and returns a JPEG data URL; it does not require a server-side Chromium process.
Windows 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 reinstallCrashes, 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 minuteRank #3
- 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.
import * as htmlToImage from 'html-to-image';
const node = document.getElementById('card');
const dataUrl = await htmlToImage.toJpeg(node, {
quality: 0.92,
backgroundColor: '#ffffff'
});
const link = document.createElement('a');
link.download = 'card.jpg';
link.href = dataUrl;
link.click();
Use this when the user already has the rendered element in a browser. The quality range is 0 to 1, unlike the integer-style quality commonly used by server-side screenshot APIs. Cross-origin images, fonts and browser security rules can affect what appears in the result.
Deployment, reliability and performance
Chromium and operating-system dependencies
The convenience package inherits Puppeteer’s browser requirements. A minimal Linux container may lack shared libraries, fonts or sandbox permissions. Install the dependencies recommended for your chosen Puppeteer deployment, or point Puppeteer at an approved compatible executable. Do not assume a development laptop’s browser setup will work unchanged in CI.
Manage browser processes
For a one-off script, launching and closing one browser is straightforward. For a service, avoid launching a new Chromium process for every request when latency matters: maintain a controlled browser or page pool, cap concurrency, close pages in a finally block, and enforce navigation and overall timeouts. Reusing a browser saves startup work but requires isolation of cookies, storage and untrusted content.
Keep inputs safe
Treat HTML and URLs as untrusted. Sanitize user-provided markup where appropriate, restrict network access, and avoid exposing internal services through server-side navigation. Set limits for HTML size, image count and render time so a single request cannot exhaust memory or CPU.
Rank #4
- 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
Troubleshooting common failures
The file is PNG, not JPG
Set type: 'jpeg' in node-html-to-image or type: 'jpeg' in Puppeteer’s screenshot options. Also use a .jpg filename and send the image/jpeg content type.
The image is blank or missing content
Check that the HTML has visible dimensions and that the selected element exists. Wait for application rendering and remote assets; use waitUntil or a page hook. If a resource is blocked, inspect its URL and server-side access rather than assuming the screenshot library is at fault.
Fonts or images differ from the browser
Verify that the rendering machine can fetch every resource, that the required fonts are installed or loadable, and that capture occurs after font and image readiness. Embed critical assets or serve them from reachable, stable URLs when reproducibility matters.
Chromium fails to launch in CI or a container
Install the operating-system libraries required by the Puppeteer build, configure a compatible executable path when your environment supplies its own browser, and review sandbox restrictions. A successful local install does not prove the production image contains the same dependencies.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →Best Value
- 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.
The process hangs
Set navigation and render time limits, investigate requests that never resolve, and always close pages and the browser in finally. Avoid waiting for network idle on pages that maintain long-lived analytics or WebSocket connections unless you also provide a bounded timeout.
Or skip the browser setup
ScreenshotNeo is a hosted screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF, so your Node.js process does not need to install or manage Chromium.
It removes cookie and consent banners, newsletter popups and chat widgets before capture. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed; the response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
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}`);
See the ScreenshotNeo documentation for request options. Every plan includes its features; the Free plan provides 1,000 screenshots per month without a card, and paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account to try it.
Which approach should you use?
- Choose node-html-to-image for a short Node.js script that turns supplied HTML into a JPG file or buffer.
- Choose Puppeteer when browser lifecycle, viewport, selectors, network behavior or authentication need explicit control.
- Choose html-to-image when the target is already rendered in the user’s browser.
- Choose ScreenshotNeo when you want a remote API, clean captures and no local Chromium maintenance.
Frequently Asked Questions
Can I convert a remote webpage URL instead of an HTML string?
Yes. Use Puppeteer with page.goto() or send the URL to ScreenshotNeo’s shot endpoint. A remote page may need authentication, custom headers or extra waiting before it is ready.
What is the difference between JPG and JPEG here?
JPG and JPEG refer to the same image format. Set the renderer’s JPEG type and use whichever filename extension your integration expects.
Why does a JPEG have a black or unexpected background?
JPEG cannot store transparency. Set an explicit background color in the page or target element before rendering.
How do I return the image from an Express route?
Call node-html-to-image without output, then send the resulting Buffer with res.type('jpg').send(buffer) after applying your own input and timeout safeguards.
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.

