What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To convert HTML to WebP in Go, first render the HTML into pixels, then encode those pixels as WebP. For pages that depend on JavaScript, CSS layout, or browser fonts, drive headless Chrome with chromedp, capture a PNG, and convert it with a Go encoder or Google’s cwebp utility. HTML is not an image format, so an encoder alone cannot render it.

Choose the right conversion path

The first decision is whether your HTML needs a browser to look right. A browser executes JavaScript and applies browser CSS, fonts, and layout. A limited HTML renderer may suit static, constrained markup, but it is not interchangeable with Chrome for arbitrary web pages.

Approach Best fit Trade-offs
Headless Chrome via chromedp, then encode Pages needing JavaScript and browser-compatible layout Requires a working Chrome/Chromium environment and process management
PNG/JPEG capture followed by cwebp When using an external encoder executable is acceptable Adds a separate tool to install and invoke
Go-side WebP encoder When you want the encoding step in Go Check the selected package’s current API and image behavior

The examples below use Chrome for rendering. The chromedp project describes its package as a Chrome DevTools Protocol client for Go; that is the project’s description, not an independent performance comparison. Its documented FullScreenshot helper describes PNG/JPEG output, so treat WebP encoding as a separate stage unless you verify direct WebP support in the exact browser protocol and chromedp version you deploy. chromedp package documentation

Render HTML to a PNG with chromedp

This example navigates Chrome to a URL, waits for the document’s load event, and writes a full-page PNG capture. It assumes Chrome or Chromium is installed and available to the process. The project README describes headless operation by default; deployment still needs a functioning browser executable and suitable runtime environment. chromedp README

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

Install the package in your Go module:

go get github.com/chromedp/chromedp

Save the following as main.go. Set TARGET_URL to a page you can access. For a local HTML file, use a file:///... URL that Chrome can read, or serve the file locally and navigate to its HTTP URL.

package main

import (
	"context"
	"log"
	"os"
	"time"

	"github.com/chromedp/chromedp"
)

func main() {
	url := os.Getenv("TARGET_URL")
	if url == "" {
		log.Fatal("set TARGET_URL to the page to capture")
	}

	ctx, cancel := chromedp.NewContext(context.Background())
	defer cancel()

	ctx, cancel = context.WithTimeout(ctx, 60*time.Second)
	defer cancel()

	var png []byte
	err := chromedp.Run(ctx,
		chromedp.Navigate(url),
		chromedp.FullScreenshot(&png, 100),
	)
	if err != nil {
		log.Fatalf("capture page: %v", err)
	}
	if len(png) == 0 {
		log.Fatal("capture returned an empty image")
	}
	if err := os.WriteFile("capture.png", png, 0644); err != nil {
		log.Fatalf("write capture.png: %v", err)
	}
}

Run it with TARGET_URL=https://example.com go run .. Here, FullScreenshot requests a full-page capture, and the documented quality value of 100 produces PNG; other documented quality values produce JPEG. The argument is not a WebP quality setting. Check the package documentation for the exact behavior of the version pinned in your module.

Wait for the page your workflow actually needs

A load event is not a universal guarantee that a page’s dynamic content is ready. Single-page apps, lazy-loaded images, delayed API responses, and web fonts can settle after navigation completes. Define a readiness condition that matches the page, such as waiting for a known selector or for a page-specific state, before capturing. No single short delay is reliable for every site.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

For repeatable output, use a fixed viewport and ensure required fonts and assets are available to Chrome. If the target page relies on scrolling to load content, account for that behavior explicitly and check the captured image rather than assuming the initial navigation loaded everything.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Encode the screenshot as WebP

Once you have raster pixels, use either a Go encoder or the cwebp command-line tool. A PNG intermediate avoids introducing JPEG loss before WebP encoding. If you start with a JPEG capture instead, converting it to lossy WebP can add another lossy encoding generation.

Option A: encode in Go

The gowebp package documentation describes a pure-Go encoder that encodes an image.Image to an output writer. It describes lossless encoding as the default and lossy encoding as an option. The following shows the pipeline shape; confirm the current package version and exact API before using it, since the documentation summarized here does not establish a version-specific constructor or option signature. gowebp package documentation

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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.
  1. Read or decode the PNG capture into a Go image.Image, using Go’s image/png decoder.
  2. Create the destination file, such as output.webp.
  3. Call the selected package version’s encoder API with the image and file writer, selecting lossless or lossy mode as appropriate.
  4. Check both the encoder error and file close/write errors; verify that the output is non-empty and opens as WebP.

Separating the capture and encoding stages also makes failures easier to diagnose: first validate the PNG, then validate the encoder output. If the package API differs from your installed version, use that version’s package documentation rather than copying an unverified function signature.

Option B: use Google’s cwebp utility

Google’s WebP guide documents converting a PNG or JPEG with this example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
cwebp -q 80 capture.png -o output.webp

-q 80 is the guide’s example value, not a universally optimal setting. Compare output quality and file size on representative pages, especially text, thin borders, gradients, and transparency. If the image contains sharp text or flat-color graphics, inspect those edges closely before settling on a lossy quality value. Google WebP cwebp guide

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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

Control dimensions, quality, and reliability

Viewport and full-page size

Set an explicit viewport when the page’s layout depends on screen dimensions. A full-page screenshot captures beyond the initial viewport, but a long page can produce a large image and use substantial memory during capture and encoding. If downstream consumers need a specific size, resize deliberately after rendering and check that text remains legible; resizing is not a substitute for capturing at the intended layout width.

Lossy or lossless output

Choose based on the content and use case. Lossless encoding preserves pixel values but may produce larger files; lossy encoding trades fidelity for smaller output. There is no universal quality setting established for HTML captures. Test representative pages and inspect both file size and visual differences. If transparency matters, verify that the selected capture and encoder path preserves alpha as expected.

Timeouts, cleanup, and concurrency

  • Bound navigation and capture time with a context deadline. Pages can hang on slow or blocked resources.
  • Cancel contexts when a job ends, including on errors, so browser work does not continue unnecessarily.
  • Check errors from browser startup, navigation, screenshot capture, file creation, encoding, and output writes separately.
  • Limit concurrent browser jobs according to the memory and process capacity of your runtime; measure your own workload rather than assuming a universal safe concurrency.
  • Make readiness conditions deterministic where possible. Arbitrary short sleeps can create intermittent blank or incomplete captures.

The chromedp README notes context cancellation behavior when the browser connection is lost and says its Linux handling force-kills Chrome child processes to avoid leaks. That does not remove the need for your application to set deadlines, cancel work, and monitor its own process lifecycle.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

  • Chrome cannot start: Confirm Chrome or Chromium is installed and discoverable in the deployment environment. A package dependency alone does not install a browser.
  • Output is PNG or JPEG, not WebP: FullScreenshot documents PNG/JPEG behavior. Add an encoding stage with a WebP encoder or cwebp; do not rename a PNG file to .webp.
  • The screenshot is blank or incomplete: Check the URL, browser access, page errors, and readiness condition. Wait for a page-specific selector or content state rather than relying on a fixed short delay.
  • Images or fonts are missing: Verify that Chrome can reach the required assets and that they are not gated behind authentication, network restrictions, or delayed loading.
  • The full-page image is unexpectedly large: Check the page length and viewport width. Capture only the needed region if full-page output is not required, or resize after capture while checking detail.
  • WebP output looks worse than expected: Confirm whether the encoder is lossy, inspect its quality setting, and compare against the PNG source. Avoid treating the documented -q 80 example as a guaranteed fit.
  • Go encoder code does not compile: Check the exact installed gowebp version and its documented API. The package’s general description does not establish one stable signature across all versions.
  • Browser processes accumulate or jobs stall: Ensure every context is canceled, use deadlines, and inspect the runtime’s Chrome process handling, especially in containers and Linux deployments.

Or skip the browser setup

If you want a screenshot without installing and managing Chrome, ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. Its clean-shot steps accept cookie/consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status.

Use this cURL request to save a WebP screenshot of a page; replace the URL with your target. See the ScreenshotNeo documentation for API details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for free and get 1,000 screenshots a month with no card.

FAQ

Can chromedp save a screenshot directly as WebP?

The reviewed FullScreenshot documentation describes PNG at quality 100 and JPEG at other documented quality values. It does not establish direct WebP output. Capture a raster image and encode it separately unless you verify WebP support for your exact browser protocol and package version.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I convert HTML without running a browser?

Only if a renderer that does not provide full browser behavior is sufficient for your markup. For JavaScript-dependent pages and browser-faithful CSS layout, use a browser rendering step.

Should I use Go encoding or cwebp?

Use a Go package if you prefer an in-process encoder and have confirmed its current API and deployment behavior. Use cwebp when an external executable fits your runtime and operational model. Compare the resulting files on your own pages; the cited documentation does not establish a universal speed or quality winner.

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.