To save a webpage screenshot as a JPEG in Go, use chromedp to drive a Chrome DevTools Protocol browser and write the screenshot bytes to a file. For a full-page image, use chromedp.FullScreenshot with a quality value other than 100: in the reviewed helper implementation, 100 selects PNG, while other quality values select JPEG. If you need explicit format control, call the lower-level DevTools Protocol screenshot method and set JPEG format and quality directly.
Choose what part of the page to capture
Before writing code, decide whether your image should show only the visible browser viewport, one element, or the entire page. These are different capture tasks, and the output filename does not determine which one you get.
- Viewport: captures the currently visible browser area. Use a viewport screenshot when the image should match what a visitor sees without scrolling.
- Element: captures a selected page element. The chromedp example repository demonstrates element capture as well as full-page capture.
- Full page: captures beyond the viewport. chromedp’s
FullScreenshothelper is intended for this case.
The example saves files with .png names, so treat it as a guide to structuring a screenshot task, not proof of JPEG encoding. Select JPEG through the helper’s quality behavior or set the protocol format explicitly. See the chromedp screenshot example.
Capture a full webpage as JPEG with chromedp
For a full-page capture, navigate to the target URL, call chromedp.FullScreenshot, and write the returned bytes to a file. The helper’s reviewed implementation selects JPEG for quality values other than 100, and PNG when quality is 100. The example below uses 90 only to demonstrate a non-100 value; it is not a universal quality recommendation.
Recommended Free Tools
#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.
package main
import (
"context"
"log"
"os"
"github.com/chromedp/chromedp"
)
func main() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
var image []byte
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.FullScreenshot(&image, 90),
)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("page.jpg", image, 0600); err != nil {
log.Fatal(err)
}
}
The result of FullScreenshot is encoded image data in a byte slice. os.WriteFile saves those bytes; it does not perform an image-format conversion. In particular, naming PNG bytes page.jpg does not make them JPEG. Keep the filename extension aligned with the selected encoding.
The code uses the chromedp Go package and its browser-driving API. The sources cited here do not establish a browser compatibility matrix or a complete browser installation procedure, so verify your local browser and package setup against the chromedp project before relying on it in a particular environment.
Use the helper for full-page capture
FullScreenshot captures beyond the current viewport. That makes it the convenient choice when you need a tall page in one image rather than just the portion currently visible. It does not mean the page is necessarily laid out exactly as it would be in a print document; it is a browser screenshot capture.
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.
Use a viewport or element task when that is what you need
Do not use a full-page helper merely because it is available. For a viewport image or a selected element, follow the corresponding task pattern in the official example and choose JPEG encoding through an API that exposes format selection. The example’s output filenames are PNG, so change the encoding behavior as well as the filename when adapting it.
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 reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchSet JPEG format and quality explicitly
At the lower-level Chrome DevTools Protocol API, the page screenshot method exposes both a format and a quality parameter. The package documentation states that screenshot format defaults to PNG and documents JPEG quality as a value from 0 through 100. Explicit settings make the intended encoding clear instead of relying on the chromedp convenience helper’s quality-100 edge case.
package main
import (
"context"
"log"
"os"
"github.com/chromedp/chromedp"
"github.com/chromedp/cdproto/page"
)
func main() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
var image []byte
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.ActionFunc(func(ctx context.Context) error {
var err error
image, err = page.CaptureScreenshot().
WithFormat(page.CaptureScreenshotFormatJpeg).
WithQuality(90).
Do(ctx)
return err
}),
)
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile("viewport.jpg", image, 0600); err != nil {
log.Fatal(err)
}
}
This direct protocol example captures the current screenshot area; it is not a substitute for the full-page helper when you need content beyond the viewport. The value 90 is an illustrative value within the documented 0–100 range, not a quality setting established as best for every page. The available sources do not provide a recommended quality value or comparative performance results.
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.
For the generated Go API and screenshot parameters, see the cdproto/page package documentation. Generated package documentation and the repository’s main branch can change, so check the API corresponding to the versions you use.
Save, inspect, and use the JPEG bytes
Both approaches produce encoded image bytes. You can write the byte slice to disk, return it from an HTTP handler with an appropriate image content type, or pass it to another part of your program. The capture format is determined before those bytes are written.
- For a file, use a
.jpgor.jpegextension only when the bytes are JPEG. - For a viewport image, ensure the browser window has the dimensions you intend to capture. The protocol screenshot method captures the current screenshot area.
- For the entire document, use
FullScreenshotand a non-100 quality value, or use a lower-level approach that explicitly handles full-page capture if your workflow requires it. - For element capture, use the example’s element task structure, while ensuring JPEG format is selected rather than assuming a filename changes the encoding.
Or skip the browser setup
If you need a screenshot from Go but do not want to manage browser capture tasks, you can make a GET request to ScreenshotNeo and write the returned image bytes. Its API can return PNG, JPEG, WebP, or PDF. The following Go example requests a JPEG for the page URL and saves the response body.
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
package main
import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"time"
)
func main() {
endpoint := "https://api.screenshotneo.com/v1/shot"
params := url.Values{}
params.Set("access_key", "YOUR_API_KEY")
params.Set("url", "https://example.com")
params.Set("format", "jpeg")
client := &http.Client{Timeout: 90 * time.Second}
resp, err := client.Get(endpoint + "?" + params.Encode())
if err != nil {
panic(err)
}
defer resp.Body.Close()
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
panic(fmt.Sprintf("screenshot request failed: %s", resp.Status))
}
image, err := io.ReadAll(resp.Body)
if err != nil {
panic(err)
}
if err := os.WriteFile("page.jpg", image, 0600); err != nil {
panic(err)
}
}
Replace YOUR_API_KEY with your API key. The API accepts the parameter names other screenshot APIs use to make switching easier; consult the ScreenshotNeo API documentation for the current request parameters and output options. Other request examples:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://example.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://example.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers report the page verdict and billing status. It also provides an MCP server with screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 shots. Sign up for ScreenshotNeo’s free plan.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Troubleshoot common JPEG capture problems
The saved .jpg file is actually PNG
A file extension never converts image data. If you used FullScreenshot with quality 100, the reviewed helper implementation selects PNG. Use a non-100 quality value for that helper, or select JPEG format explicitly with the protocol method, then save the resulting JPEG bytes with a JPEG extension.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →The screenshot contains only the visible portion
The direct page.CaptureScreenshot example captures the current screenshot area. Use chromedp.FullScreenshot for a full-page capture that extends beyond the viewport.
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 image is not the element you intended
A full-page capture and an element capture are distinct tasks. Use the element task pattern in the chromedp example when the desired output is one selected element, and confirm that the task still sets JPEG encoding. The example’s PNG filenames do not establish JPEG output.
The request or browser task returns an error
Check the error returned by chromedp.Run before writing a file. For the API alternative, check the HTTP status and response body handling rather than saving an error response as an image. The sources do not define a complete error-code catalog or browser setup checklist, so diagnose the returned error against the documentation for the versions and environment in use.
Performance, reliability, and cost considerations
Capturing a webpage requires the page to load and render in the browser before its image can be produced. The cited chromedp sources describe screenshot behavior but do not establish timing benchmarks, a browser compatibility guarantee, or a cost estimate for running browser automation. For a production workload, decide whether you need viewport, element, or full-page capture, handle errors before persisting bytes, and verify the output encoding rather than inferring it from the filename.
An API-based service trades local browser setup and task management for an external request and service-specific billing. ScreenshotNeo states that only clean shots are billed and identifies non-billable bot checks, blank pages, timeouts, failed loads, and cache hits in response headers; use those headers to distinguish outcomes. Its plan limits and prices are listed on its site and can change, so check the current plan details when estimating recurring usage.
Frequently Asked Questions
Does chromedp’s screenshot example produce JPEG files?
No. The example writes PNG-named files. It demonstrates screenshot task structure; select JPEG encoding separately.
What quality number should I use for JPEG?
The cited sources establish the parameter range and helper behavior, not an ideal quality number. Choose and validate a value for your own image and file-size requirements.
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.

