To convert an arbitrary HTML page into an image in Deno, render it in a real browser and capture the page. Deno 2 can use npm packages such as Playwright or Puppeteer. A canvas export is a different operation: it serializes pixels that are already drawn on a canvas; it does not, by itself, lay out arbitrary HTML and CSS.
This guide shows the browser-automation approach, explains Deno permissions and browser installation, and covers the cases where canvas export is sufficient. The exact import and browser-launch details can vary by library version, so check the selected package’s current official documentation before pinning a production recipe.
Choose the rendering model first
| Input | Use | What it can render |
|---|---|---|
| Complete HTML document or URL | Browser automation (Playwright or Puppeteer) | HTML, CSS, web fonts, images, and client-side JavaScript as a browser sees them |
| Pixels already drawn into a canvas | HTMLCanvasElement.toDataURL() or toBlob() |
The existing canvas bitmap; it does not interpret a normal HTML document |
For a webpage screenshot, the browser route is the relevant model. Deno’s canvas API is appropriate when your program already produced the graphic with canvas drawing commands.
Prerequisites in Deno 2
- Deno 2 (or a version compatible with the browser library you select).
- An installed, compatible browser binary, or a package setup that downloads one.
- Permission to access the target and write the output file.
- A package installation method that permits any required lifecycle or post-install script.
Deno recommends ECMAScript modules for new code and supports npm packages through its npm compatibility layer. Deno’s 2024 documentation specifically identifies Playwright as an npm package that can be used. Compatibility is not identical for every package, however; validate imports, launch options, and browser installation for the version you deploy.
#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.
Browser screenshot example with Playwright
The following is a minimal pattern for a remote page. Treat the package import and browser executable configuration as version-sensitive: confirm them against the current Playwright guide for your chosen Deno release.
import { chromium } from "npm:playwright";
const browser = await chromium.launch();
const page = await browser.newPage({
viewport: { width: 1440, height: 900 },
deviceScaleFactor: 1,
});
await page.goto("https://example.com", { waitUntil: "networkidle" });
await page.screenshot({
path: "page.png",
fullPage: true,
type: "png",
});
await browser.close();
Save it as screenshot.ts. The call to fullPage: true captures the document’s complete scrollable height. Set it to false for only the viewport. PNG is lossless; where your library supports it, JPEG or WebP can reduce file size with different quality controls.
Run with narrowly scoped permissions
deno run --allow-net=example.com --allow-write=page.png screenshot.ts
A remote target needs network permission, and writing page.png needs filesystem permission. Grant only the domains and paths your script actually uses. Avoid broad flags such as unrestricted network or filesystem access when a scoped permission is practical.
When browser launch fails
Puppeteer’s package instructions warn that package managers, including Deno, may block install scripts. If the install script is blocked, the browser is not downloaded automatically. Permit the package’s required installation step according to its current instructions, or install a compatible browser manually and pass its executable path using the library’s documented launch option. The same principle applies to any automation package that separates JavaScript installation from browser binaries.
Recommended Free Tools
Make the capture reflect the final page
Wait for client-side rendering
networkidle can help when a framework fetches data after navigation, but it is not a guarantee that every animation, font, or delayed component is finished. For deterministic output, wait for a selector that identifies the finished state, add a measured delay only when necessary, or explicitly wait for fonts and images using APIs supported by your automation library.
Images, fonts, and lazy loading
Lazy-loaded images may not exist until they enter the viewport. A full-page capture can trigger loading in some browsers, but do not assume that behavior for every site. If images are missing, scroll through the page or use the site’s own “loaded” marker before taking the shot. Ensure external font requests have completed before capture if typography matters.
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.
Viewport, scale, and format
- Viewport: choose width and height that match the consumer of the image.
- Device scale factor: a higher scale produces sharper pixels but increases memory and file size.
- Full page: useful for documentation and long pages; very tall pages can exceed image or memory limits.
- Element capture: capture a specific CSS selector when a whole-page image contains irrelevant navigation.
- Format: use PNG for crisp text or transparency, JPEG for photographic content, and WebP when your downstream tools accept it.
Dynamic and hostile pages
Pages with consent dialogs, login walls, bot checks, cross-origin restrictions, or unstable third-party scripts may not produce the same result on every run. Supply the required cookies or headers through documented browser APIs, and treat a CAPTCHA or blank response as a failed capture rather than a valid image.
Canvas export: only for canvas content
If your application already draws the image into a canvas, export that canvas instead of launching a browser. Deno documents PNG as the default MIME type for canvas image serialization.
const canvas = document.querySelector("canvas");
if (!(canvas instanceof HTMLCanvasElement)) {
throw new Error("No canvas element found");
}
const pngDataUrl = canvas.toDataURL("image/png");
console.log(pngDataUrl);
This example assumes a DOM environment that provides document and HTMLCanvasElement. It does not convert a string such as <h1>Hello</h1> into a styled webpage image. For that, render the string in a browser page and capture the result.
A practical decision checklist
- Are you converting a whole document or URL? Use browser automation.
- Is the artwork already in a canvas? Use canvas serialization.
- Do you need JavaScript, responsive CSS, web fonts, or layout fidelity? Use a browser.
- Can the deployment environment install or reach a browser binary? Verify this before choosing the runtime.
- Do you need a repeatable service rather than browser maintenance? Consider a screenshot API.
Troubleshooting Deno HTML-to-image jobs
“Module not found” or import errors
Confirm that the import uses the package syntax supported by your Deno version, that the package name and version are current, and that your file is treated as an ECMAScript module. Do not copy an import from a different major version without checking that version’s API.
Browser executable not found
Check whether the package’s install script was blocked and whether its browser download completed. Install the required browser manually or configure the documented executable path. A JavaScript package alone is not always a browser binary.
Permission denied
Map the operation to a permission: navigation and asset requests need network access; output files need write access; environment variables or subprocess-based browser launches may need their corresponding permissions. Add the narrowest scope that fixes the error.
Free tools Windows power users keep installed
One-click scans. No signup required.
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.
The image is blank or incomplete
Inspect the page in a normal browser, verify the URL, wait for a known ready selector, and check that the page did not return a bot challenge, authentication screen, or JavaScript error. Scroll or trigger lazy loading before capture when required.
Fonts or images differ between runs
Use a consistent browser version, viewport, device scale factor, timezone, and network conditions. Wait for fonts and image requests, disable animations where your library supports it, and avoid capturing while content is still changing.
The process runs out of memory
Prefer viewport or element captures for very long pages, lower the device scale factor, close each browser context, and process URLs in bounded batches. A tall full-page bitmap can be much larger in memory than its compressed file suggests.
Performance, reliability, and deployment notes
Launching a browser is usually more expensive than reusing one. For multiple captures, keep one browser process and create isolated pages or contexts, then close them promptly. Limit concurrency to what the host can support; excessive parallel pages increase CPU, memory, and network contention.
For reliable jobs, record the target URL, viewport, browser version, wait condition, output format, and failure reason. Retry transient navigation failures with a limit and backoff, but do not blindly retry a deterministic CAPTCHA or authorization failure. Store outputs atomically so a crashed process does not leave a partial file that looks valid.
Deno’s permission sandbox is useful in production: scope network access to approved hosts and filesystem access to an output directory. Review whether the chosen automation library launches a subprocess or reads environment variables, then grant only the additional permissions it actually requires.
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
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF, while the service accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Those cleanup steps can be switched off individually.
Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response reports the result in X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
For Deno or any HTTP-capable client, call the API directly:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for authentication and options. The same request in Python is:
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)
And in 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}`);
ScreenshotNeo includes full-page and CSS-selector captures, dark mode, device presets and custom viewports, retina scale, PDF controls, HTML/CSS-to-image, custom CSS and JavaScript, click and wait actions, request blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed image links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API, and an OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify migration.
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to start.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →FAQ
Can Deno convert an HTML string without a URL?
Yes. Create a browser page, set its content with the automation library’s documented HTML-content method, wait for resources, and capture the page. The rendering still happens in a browser; canvas export alone is not a replacement.
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.
Should I choose Playwright or Puppeteer?
Both are browser-automation approaches, and Deno can use npm packages. Select the library whose current Deno import, browser installation, and deployment documentation match your environment rather than assuming identical APIs.
Is a screenshot the same as printing HTML to PDF?
No. A screenshot is a raster image of rendered pixels. PDF output follows print pagination and paper settings, so it is a separate capture mode with different layout behavior.
Frequently Asked Questions
Can Deno convert an HTML string without a URL?
Yes. Load the string into a browser page with the selected automation library, wait for its resources, and capture the page.
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 →Is canvas export enough for a complete webpage?
No. Canvas APIs serialize pixels already drawn on a canvas; arbitrary HTML and CSS require browser rendering.
The Bottom Line
Use browser automation when the input is HTML; use canvas serialization only for an existing canvas graphic. Scope Deno permissions, verify the selected package’s current browser setup, and wait for the page’s real ready state before capturing.
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.

