To convert a folder of HTML files to JPG, render each file in a browser and save a screenshot as a JPEG. For pages that use modern CSS, JavaScript, web fonts, or dynamic content, a headless browser such as Playwright or Puppeteer is the most faithful general-purpose choice. Loop over the files, wait for the page to finish rendering, and give each output a predictable name. Renaming an .html file to .jpg does not convert it.
Choose a conversion method
HTML is markup, not an image. The conversion step must lay out the page and render it before saving its pixels as a JPG. The right tool depends on how the pages are built and how much control you need over timing, output dimensions, and repeatability.
| Method | Best suited to | Important trade-off |
|---|---|---|
| Playwright or Puppeteer | Modern pages with JavaScript, CSS, fonts, and dynamic content; automated batches | Requires installing and maintaining a browser automation environment |
wkhtmltoimage |
Simple pages and quick command-line conversion | Check your pages carefully before relying on it for modern JavaScript or CSS; rendering can differ |
| ImageMagick | Resizing, quality adjustment, or converting already-rendered images | It is post-processing, not an HTML renderer |
Playwright’s CLI documentation describes both viewport and full-page screenshots and lists JPEG as a supported format (Playwright screenshot and PDF commands). Puppeteer likewise documents capturing screenshots with Page.screenshot() (Puppeteer screenshots). For a simple static page, wkhtmltoimage accepts HTML pages and can save JPG or PNG (wkhtmltoimages README).
Batch-convert files with Playwright and Node.js
A Node.js script is a practical option for an unattended folder conversion: it can launch one browser, open files one by one, wait for rendering, and write JPEGs under deterministic names. The example below expects files in html/ and writes images to jpg/. It captures each page at a consistent viewport size; remove the fixed viewport and use full-page capture when you need the entire document.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- One-click Process for Converting Your Images
- Convert Between All Key Image Format
- Preserve Vector Graphics When Converting
1. Install Playwright
Install Node.js, create a working folder, and add Playwright:
npm init -y
npm install playwright
npx playwright install chromium
2. Save the conversion script
Save this as convert.mjs in the working folder. It uses file URLs, creates the output folder if needed, and reports failures per input file rather than stopping the whole batch.
import { chromium } from 'playwright';
import { readdir, mkdir } from 'node:fs/promises';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
const inputDir = path.resolve('html');
const outputDir = path.resolve('jpg');
const fullPage = true;
const quality = 85;
await mkdir(outputDir, { recursive: true });
const files = (await readdir(inputDir))
.filter(name => name.toLowerCase().endsWith('.html'))
.sort((a, b) => a.localeCompare(b));
if (files.length === 0) {
throw new Error(`No .html files found in ${inputDir}`);
}
const browser = await chromium.launch({ headless: true });
try {
for (const name of files) {
const inputPath = path.join(inputDir, name);
const outputName = `${name.replace(/.html$/i, '')}.jpg`;
const outputPath = path.join(outputDir, outputName);
const page = await browser.newPage({ viewport: { width: 1440, height: 1000 } });
try {
await page.goto(pathToFileURL(inputPath).href, { waitUntil: 'networkidle', timeout: 30000 });
await page.evaluate(() => document.fonts.ready);
await page.screenshot({ path: outputPath, type: 'jpeg', quality, fullPage });
console.log(`Saved ${outputPath}`);
} catch (error) {
console.error(`Failed ${inputPath}: ${error.message}`);
} finally {
await page.close();
}
}
} finally {
await browser.close();
}
The script’s networkidle wait is a starting point, not a universal guarantee. Pages with persistent analytics or long-polling connections may never become idle; pages that draw content after network activity ends may need an additional wait for a selector or app-specific ready signal. Adjust the wait to the page rather than assuming one delay fits every file.
3. Run it and check the output
Place HTML documents under html/, then run:
node convert.mjs
Each input such as report.html produces jpg/report.jpg. The script sorts the input list and keeps the original base names. Review several representative outputs, particularly the longest page and one with the most complex assets, before running a large batch.
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 errorsRank #2
- ONGOING PROTECTION Download instantly & install protection for 5 PCs, Macs, iOS or Android devices in minutes!
- TOP-PERFORMING VPN Faster speeds, more server locations, and greater connection control to protect your privacy across all your devices, including Smart TVs.
- ADVANCED SCAM PROTECTION Help spot hidden scams online. With the built-in Genie AI assistant, you’ll never wonder if a message or email is suspicious again.
- REAL-TIME PROTECTION Advanced security protects against existing and emerging malware threats, including ransomware and viruses, and it won’t slow down your device performance.
- DARK WEB MONITORING Identity thieves can buy or sell your information on websites and forums. We search the dark web and notify you should your information be found.
Use viewport or full-page capture deliberately
A viewport screenshot captures what fits in the browser window. It works for a fixed-size preview, a card, or a page where only the initial screen matters. A full-page screenshot captures the whole scrollable document and is usually the better choice for reports and standalone HTML documents.
In the sample script, set fullPage = true for the whole document or false for the viewport. A fixed viewport width also affects line wrapping and therefore the page’s height. Pick the width that matches the intended use, then keep it consistent across the batch. Extremely tall pages can produce unwieldy images; split them into sections or use a deliberate maximum-size workflow if the receiving system has image-dimension limits.
Handle local assets and dynamic pages
Local HTML files can reference images, stylesheets, fonts, or scripts by relative path. Keep their directory structure intact when converting, and test that those assets load from the file URL. Some browser features, including module scripts or fetch requests, require an origin and may not work when a document is opened as file://. If that applies, serve the folder over a local HTTP server and navigate to its local URL instead.
For pages that depend on client-side rendering, wait for the rendered content—not just the initial document response. You can wait for a known element before capturing:
Recommended Free Tools
Rank #3
- Convert images to jpeg, gif, png, bmp, tiff and more
- Rotate, resize and compress digital photos
- Easily add captions or watermarks to your images
- Compress thousands of photos at a time with batch conversion
- Convert images directly from the right-click menu
await page.goto(url, { waitUntil: 'domcontentloaded' });
await page.locator('#report-ready').waitFor({ state: 'visible', timeout: 15000 });
await page.evaluate(() => document.fonts.ready);
await page.screenshot({ path: outputPath, type: 'jpeg', quality: 85, fullPage: true });
Replace #report-ready with a selector your page actually renders when it is ready. If images are lazy-loaded below the fold, scrolling through the page before capturing can trigger them; verify that the images appear in the output instead of assuming a screenshot automatically loads every lazy asset.
Use wkhtmltoimage for simpler pages
For straightforward HTML that renders correctly in your installed version, a shell loop can call wkhtmltoimage once for each file. The project documents local HTML input and JPG output. This route is easy to understand, but do a visual check first for pages relying on modern CSS or JavaScript; the provided documentation does not establish compatibility for every page or version.
mkdir -p jpg
for f in html/*.html; do
[ -e "$f" ] || continue
base=$(basename "$f" .html)
wkhtmltoimage "$f" "jpg/$base.jpg"
done
The guard avoids passing the literal pattern to the command when the folder contains no matching HTML files in shells where unmatched globs are left unchanged. If filenames contain unusual characters, use a more robust script or a null-delimited file loop appropriate to your shell. Keep output in a separate directory so a rerun cannot overwrite the source files.
Set JPEG quality and post-process images
JPEG is lossy: lowering quality can reduce file size, but it can also soften small text, fine lines, and detailed graphics. In the Playwright example, quality is an integer from 0 to 100; 85 is simply an editable starting value, not a guaranteed best setting. Inspect the output at its intended display size and compare a few quality settings before choosing one for a production batch.
Rank #4
- SONY IMAGE CONVERTER 2 SOFTWARE
If fidelity matters more than compact delivery—or if transparency is needed—keep a PNG master and create JPEG derivatives only when required. JPEG does not preserve transparency. ImageMagick is useful for resizing or converting rendered images; it is not the step that renders HTML. Its command-line documentation covers filename globbing and numbered output patterns (ImageMagick command-line processing).
magick 'rendered/*.png' -quality 85 'jpg/page-%03d.jpg'
This converts a set of rendered PNGs into numbered JPEG files. Quote the glob so ImageMagick processes the pattern, and choose a different output directory or naming scheme when matching source and output names is important.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If you would rather send a URL to a screenshot API than install and run a browser locally, ScreenshotNeo takes one GET request for a web page and returns an image or PDF. For JPG output, make the format explicit with format=jpeg:
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
See the ScreenshotNeo API documentation for request parameters. Its clean-shot options accept cookie or consent banners as a visitor and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. An MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. A URL-based API captures web pages, so for local HTML you would first need to make the page available at a URL.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
Best Value
- Convert JPG, JPEG & PNG to PDF
- Select multiple images
Troubleshoot common conversion problems
- The output is blank or missing content. Confirm the input path and that the page opens in the same browser environment. Check for scripts or assets blocked by
file://, then serve the folder over local HTTP if those features need an origin. For JavaScript-rendered pages, wait for a ready selector. - Fonts or images are absent. Verify relative paths and permissions, and check that the assets load before capture. Wait for
document.fonts.ready; for lazy-loaded images, trigger loading by scrolling or use a page-specific readiness condition. - The script times out on some pages. A page may keep network connections open, so
networkidlemay not occur. Use a more appropriate navigation condition and wait for a known element, or set a timeout suitable for the page. Log failed filenames so you can rerun only those inputs. - Some files are skipped or filenames do not match. The example accepts files ending in
.htmlcase-insensitively and writes the same base name with.jpg. Confirm the input folder and extension; use a more careful naming rule if files have duplicate base names in nested folders. - The JPEG looks soft or text is hard to read. Raise the JPEG quality, choose an appropriate viewport width, or retain PNG for the master. JPEG compression is lossy, especially noticeable on fine text and edges.
- The full-page image is too tall. Check whether the entire document is actually needed. Use viewport capture for previews, or divide long documents into sections if the destination imposes image-size limits.
- The command cannot find the browser or renderer. Complete the browser installation step for Playwright, or install the chosen command-line renderer for your operating system. Verify it is available on the shell’s PATH before starting a large batch.
Cost, repeatability, and reliability
For local conversion, the main operational costs are setup and maintenance: the browser or renderer must be installed, and the script must handle page-specific waits and failures. Reusing one browser for a batch avoids launching it for every file, while opening a fresh page per document isolates page state. The example closes each page and the browser in finally blocks so one failed capture does not leave the batch’s resources open.
Make runs reproducible by keeping a stable viewport, naming scheme, browser version, and quality choice. Write images to a separate directory and retain an error log or console output. A successful process exit is not proof that every page rendered correctly: inspect samples, especially after changing browser versions, source assets, or page scripts.
Frequently Asked Questions
Can I convert HTML to JPG without opening each file manually?
Yes. A batch script can loop through the files and capture each page with a headless browser, or invoke a command-line renderer per file.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Does renaming an HTML file to .jpg work?
No. The page must be rendered into image pixels; changing the extension does not convert its contents.
Should I save screenshots as JPG or PNG?
Use JPG when compact delivery matters and minor compression loss is acceptable. Keep PNG when crisp text or transparency matters.
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.




