What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
To convert HTML text to JPG, render the HTML in a browser and export the result as a JPEG. For a quick, user-triggered capture inside a webpage, use html2canvas. For server-side jobs that need browser CSS and JavaScript, use Puppeteer or Playwright. For a compact command-line workflow, use wkhtmltoimage after checking that it handles your page correctly.
The key choice is whether you need a convenient DOM-based image, a screenshot from a real browser, or a command-line conversion. This guide shows each method, explains the trade-offs, and covers common failures such as missing images, fonts, or content.
Which method should you use to convert HTML text to JPG?
Choose based on where the conversion runs and how closely the JPG must match what a browser displays.
| Method | Best fit | Important trade-off |
|---|---|---|
| html2canvas | A visitor clicks a button to save an element from the current page. | It reconstructs a rendering from DOM information; it is not a pixel-perfect browser screenshot. CSS support is selective, and browser cross-origin rules still apply. |
| Puppeteer or Playwright | Server-side or automated captures where a real browser should render the page. | You must run and manage a browser process, and explicitly wait for the page content you need. |
| wkhtmltoimage | A concise command-line conversion or batch workflow. | Test your site’s modern CSS, fonts, and JavaScript behavior before relying on it. |
For one text element in an interactive page, start with html2canvas. For repeatable output in a backend pipeline, use a headless browser. If you need a screenshot of an existing website rather than a local HTML document, a screenshot API can avoid setting up and maintaining the browser yourself.
#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.
Convert HTML text to JPG in the browser with html2canvas
This example captures an element, creates a JPEG data URL, and prompts the visitor to download it. It uses the html2canvas browser build shown in the project’s example; adapt the selector and filename to your page.
<div id="capture">HTML text to render</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas-next/1.8.0/html2canvas.min.js"></script>
<script>
html2canvas(document.querySelector('#capture'), {
scale: window.devicePixelRatio,
useCORS: true
}).then(canvas => {
const jpg = canvas.toDataURL('image/jpeg', 0.92);
const link = document.createElement('a');
link.download = 'html-text.jpg';
link.href = jpg;
link.click();
});
</script>
The quality value 0.92 is an example setting, not a universal optimum. JPEG quality trades file size against compression artifacts. Text on a plain background often needs a higher quality setting than a small preview image.
Install and integrate the library
The example loads a browser script from a CDN. The project also documents npm installation and Promise-based use; choose the integration that fits your build system. In production, pin and serve the version you have tested rather than relying on an unversioned dependency.
Make the output readable
- Capture a specific element rather than the entire document when only a text block is needed.
- Use a sufficiently large capture scale for the expected display size.
window.devicePixelRatiois a convenient starting point, but high values increase memory use. - Set a solid background on the captured content. JPEG does not support transparency, so transparent regions may not produce the background you expect.
- Wait until fonts, images, and client-rendered content are ready before calling html2canvas.
Understand its fidelity limits
html2canvas builds an image using information available in the DOM rather than taking a native screenshot of the browser. Its documentation cautions that the result may not exactly match the real representation. It also implements CSS properties selectively, so compare the output against the page in your target browser before depending on it for precise layout.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesBrowser content policies remain in force. The library cannot bypass cross-origin restrictions for images, and cross-origin iframes cannot be rendered. For an image from another origin, that origin must permit access with suitable CORS headers, or you may need to serve the asset through a same-origin proxy.
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.
Convert HTML text to JPG on a server with Puppeteer
Puppeteer drives a real browser, which makes it a better fit for backend generation when browser CSS and JavaScript behavior matter. Install Puppeteer in your Node.js project, then run a script such as this in an environment where its browser can launch:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setViewport({ width: 1200, height: 800, deviceScaleFactor: 1 });
await page.setContent(
'<html><body><h1>HTML text</h1></body></html>',
{ waitUntil: 'networkidle0' }
);
await page.screenshot({
path: 'html-text.jpg',
type: 'jpeg',
quality: 92,
fullPage: true
});
} finally {
await browser.close();
}
The script uses an explicit viewport and closes the browser in a finally block so an error does not leave the process open. The requested networkidle0 condition waits for network activity to become idle, but it does not guarantee that every application’s client-side rendering, custom font, or delayed content is finished. If your page has a known completion signal, wait for that selector or state before capturing.
Set dimensions and capture scope deliberately
Choose the viewport width and height to match the layout you intend to render. A full-page screenshot captures the full document, which can be much taller than the initial viewport. If you only need a particular region, select or clip that region rather than producing an unnecessarily large image. Test the dimensions with the longest expected page: very large captures can be slow or exceed browser or image limits.
Puppeteer’s Page API documents page.setContent(...) and page.screenshot(...). The html2canvas FAQ points to Puppeteer or Playwright for server-side screenshot generation when a real headless browser is needed.
Convert an HTML file to JPG from the command line
For a local file, the documented wkhtmltoimage command shape is:
Rank #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.
wkhtmltoimage --quality 90 input.html output.jpg
Replace input.html with your HTML file’s path and output.jpg with the desired output path. The project README also documents URL input and conversion to JPG or PNG. Check the installed program’s help or its documentation for the options supported by your build.
The quality value 90 is an example command setting. Before using this in a batch job, test representative pages for layout, modern CSS, web fonts, and JavaScript-dependent content. A successful command only means a file was produced; it does not prove the result matches the browser view.
Or skip the browser setup
If you are capturing an existing public website, ScreenshotNeo can return a screenshot from one GET request. For example, this cURL command requests a WebP image of Stripe and saves the response:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
For a local HTML string or file that is not hosted at a URL, use one of the methods above; this API call takes a URL to capture. See the ScreenshotNeo API documentation for authentication, output formats, and capture parameters.
- Cookie banners are accepted and removed before capture, along with supported newsletter popups and chat widgets; each cleanup step can be turned off.
- Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers identify the page verdict and billing status.
- An MCP server provides
take_screenshot,get_page_info, andcapture_pdftools for AI agents and MCP clients. - The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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
Choose the right output settings
JPEG quality and file size
JPEG compresses images with loss, so repeated re-encoding can degrade the result. Use a quality value that keeps small text and sharp edges legible at the image’s intended display size. There is no single setting that is best for every page; inspect the output and adjust it for your use case.
Background and transparency
JPG has no alpha channel. If the source has transparent areas, put the content on a solid background before rendering or flatten it onto a chosen background in a post-processing step. If transparency is required, use a format that supports it, such as PNG or WebP, rather than JPG.
Fonts, images, and asynchronous content
For externally hosted fonts and images, ensure they can be fetched by the rendering environment. Wait for fonts and images to load, and for client-side code to finish creating the content. This matters both in browser-side capture and in headless browser jobs: the capture APIs provide ways to render and save, but cannot know when arbitrary application logic is ready.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshooting HTML-to-JPG conversion
The image is blank or only partly rendered
- Likely cause: The capture ran before the page or client-side application finished loading, or the output dimensions were too large.
- Fix: Wait for a meaningful selector or application-ready state. For Puppeteer, set an explicit viewport and test a smaller capture to distinguish timing problems from canvas or image-size limits.
Images are missing or html2canvas reports a security problem
- Likely cause: An image is cross-origin and the browser’s CORS policy does not allow it to be read into a canvas.
- Fix: Configure suitable CORS headers on the asset, serve it from the same origin, or use a same-origin proxy.
useCORS: truedoes not override a server’s policy. Cross-origin iframe contents cannot be rendered by html2canvas.
The JPG differs from the browser page
- Likely cause: html2canvas does not reproduce every CSS property exactly, or a dependency such as a font has not loaded. A command-line renderer may also handle modern CSS or JavaScript differently.
- Fix: Compare against a real-browser screenshot using Puppeteer or Playwright, confirm assets are loaded, and test the exact browser and page styles your workflow requires.
The text looks soft or the output is too large
- Likely cause: The capture scale, output dimensions, or JPEG quality do not match the intended use.
- Fix: Adjust the capture scale and quality, then inspect at the actual display size. Higher scale and quality can increase file size and processing cost.
The command succeeds but the page is incomplete
- Likely cause: The page depends on JavaScript, modern styling, delayed resources, or behavior unsupported by the selected renderer.
- Fix: Test the same input in a current browser. If browser execution is essential, use a headless browser workflow and wait for page readiness.
Performance, reliability, and cost considerations
Browser-side html2canvas avoids a server browser process, but large elements and high device scale can consume substantial client memory and make the page less responsive while capturing. It also depends on the visitor’s browser and access to all required assets.
Headless-browser rendering adds browser startup, memory, and process-management work to a server job. Reuse browser processes where appropriate in a controlled service, isolate jobs, set timeouts, and close pages and browsers when finished. For many URLs, control concurrency so rendering jobs do not exhaust memory or CPU. The best settings depend on the page and deployment environment; benchmark your own representative workload rather than assuming a fixed throughput.
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.
wkhtmltoimage offers a short command for automation, but compatibility should be established against your own pages before it becomes a dependency. ImageMagick can inspect or transform a rendered image, but it is not an HTML layout engine and cannot replace a browser or HTML renderer.
Frequently asked questions
Can I convert plain HTML text without a website?
Yes. Put the text in a small HTML document or element and render it with html2canvas, Puppeteer, or wkhtmltoimage. A screenshot API that accepts a URL is for pages reachable at a URL, not an arbitrary local string.
Can I save HTML as JPG without JavaScript?
Yes. The wkhtmltoimage command-line example does not require you to write JavaScript. For automated server captures, Puppeteer’s script is JavaScript, while the browser-side html2canvas example uses JavaScript to export the image.
Should I choose JPG or PNG for text?
Use JPG when a smaller lossy photograph-like image is acceptable and transparency is unnecessary. For crisp text edges, graphics, or transparency, compare PNG as an alternative because it avoids JPEG’s lossy artifacts.
Recommended Free Tools
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.

