chromedp is a Go client for automating Chrome-family browsers through the Chrome DevTools Protocol (CDP). You add it to a Go module, make Chrome or Chromium available to the process, create a chromedp context, and run browser actions such as opening a URL, waiting for an element, and reading page content. Chrome runs headlessly by default, so a successful first program may not display a window.
This guide builds a minimal working program, explains browser visibility and cleanup, and shows where to go next for larger workflows.
What chromedp does
chromedp is a high-level Go client for browser automation through the Chrome DevTools Protocol. Your Go code sends CDP commands to a supported Chrome-family browser rather than driving a separate desktop application. Typical uses include scraping, automated tests, profiling, and scripted browser actions.
The project describes chromedp as “a faster, simpler way to drive browsers supporting the Chrome DevTools Protocol in Go without external dependencies.” That is the project’s positioning, not an independently measured performance claim. The API reference documents the package surface, while the project’s examples repository demonstrates complete workflows.
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 match#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.
chromedp is a Go module dependency. You still need a browser executable that the process can start, or an already-running browser instance to which it can connect.
Prerequisites and version expectations
- A working Go toolchain and a directory for a Go module.
- Chrome or Chromium installed and available to the process.
- A project decision about the exact Go, chromedp, and browser versions you will use.
The consulted project documentation does not publish a current compatibility matrix. Verify the versions selected for your project together rather than assuming that any combination is supported.
Create a Go module and add chromedp
- Create a project directory and initialize a module.
mkdir chromedp-start cd chromedp-start go mod init example.com/chromedp-start - Add the dependency. The project README documents this command:
go get -u github.com/chromedp/chromedpIt is the README’s documented workflow; whether you should use an update flag in a particular project depends on that project’s dependency policy.
- Create
main.gowith a small navigation-and-read program.
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/chromedp/chromedp"
)
func main() {
// The timeout bounds the whole browser task.
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
var title string
var body string
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.Title(&title),
chromedp.Text("body", &body, chromedp.NodeVisible),
)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Title: %snn%sn", title, body)
}
Run it with:
go run .
The program creates a context, navigates to https://example.com, reads the document title and visible body text, and exits. The deferred cancellation releases the context when main returns.
How the first run works
Context controls the session
chromedp uses Go contexts to represent browser work. The timeout in the example prevents a navigation or extraction from waiting indefinitely. Calling cancel ends the work when the function finishes or when you decide to stop it earlier.
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.
Actions run in order
chromedp.Run executes the supplied actions sequentially. Navigation must occur before title or text extraction. For real pages, add an action that waits for the selector or state your task needs before reading data.
Headless is the default
Chrome runs headlessly by default, so no window is expected to appear. A successful command can therefore produce terminal output while nothing is visible on your desktop. This is normal, not evidence that chromedp failed.
Make Chrome visible while debugging
When you need to watch navigation, inspect a login flow, or diagnose a selector, configure the allocator options instead of relying on the defaults. The README points to DefaultExecAllocatorOptions for changing Chrome’s default behavior.
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 →package main
import (
"context"
"log"
"time"
"github.com/chromedp/chromedp"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
opts := append(chromedp.DefaultExecAllocatorOptions[:],
chromedp.Flag("headless", false),
)
allocCtx, allocCancel := chromedp.NewExecAllocator(ctx, opts...)
defer allocCancel()
taskCtx, taskCancel := chromedp.NewContext(allocCtx)
defer taskCancel()
if err := chromedp.Run(taskCtx,
chromedp.Navigate("https://example.com"),
); err != nil {
log.Fatal(err)
}
// Keep the browser open briefly so it can be observed.
time.Sleep(5 * time.Second)
}
This example is for local diagnosis. For unattended jobs, headless operation is generally the expected mode. If your installed browser does not accept the selected option, check the browser executable and the precise versions used by your project.
Use an existing Chrome instance
chromedp can either start Chrome or connect to an instance that is already running. The project FAQ documents manually starting a long-running Chrome instance and connecting with RemoteAllocator. This approach is useful when browser startup is managed outside your Go process or when several tasks share a controlled browser endpoint.
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 connection lifecycle remains your responsibility: ensure the existing instance is reachable, keep its debugging endpoint protected, and cancel contexts when work ends. The README also notes Linux-specific cleanup behavior for browsers chromedp starts: it force-kills started Chrome child processes to avoid resource leaks. That behavior is different from managing a separately started, long-running instance.
Expand the example safely
Wait for a page condition
Modern pages may render content after the initial navigation completes. Use a selector-based wait before reading the value you need. Choose a selector that represents the state your task actually requires, and retain a context timeout so a missing element becomes a bounded failure.
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 →Repair Windows errors before they cause bigger problemsFix Now →Capture errors with useful boundaries
Wrap each logical browser operation in its own function or task list. Log the URL and operation when returning an error, but avoid logging credentials or sensitive page content. A timeout, a closed browser connection, and an explicit context cancellation can all stop a run; the surrounding operation should identify which stage was active.
Keep browser work isolated
Create a parent context for the browser allocation and child contexts for individual jobs. Cancel a child after each job so a failed navigation does not leave pending work attached to the next one. For concurrent jobs, design the browser and context ownership deliberately rather than sharing mutable page state accidentally.
Lifecycle and common first-run failures
“I cannot see a browser window”
Headless mode is the default. Use allocator options to disable headless mode while debugging, or add logging and inspect the returned values in a headless run.
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
Chrome cannot be started
Confirm that Chrome or Chromium is installed and that the process can locate the executable. In a service, container, or restricted account, check the runtime user’s environment and permissions. If your deployment starts Chrome separately, use the documented remote-connection approach instead of asking chromedp to launch another process.
The command ends with context canceled
Context cancellation can be an intentional result of your timeout or deferred cleanup. It can also surface when the browser connection is lost. Check whether the deadline was reached, whether your code called the cancel function early, and whether the browser process exited. Increase the timeout only after confirming that the page legitimately needs more time.
Navigation succeeds but extraction is empty
The requested node may not exist yet, may be hidden, or may be inside a different document state than expected. Add a wait for the relevant selector and use the appropriate visibility condition. Also verify that the URL redirects to the page you think you are reading.
Linux leaves unexpected processes or fails under a supervisor
The README documents force-killing Chrome child processes that chromedp starts on Linux to avoid resource leaks. If your service needs a long-running browser, start it explicitly and connect with RemoteAllocator, then manage that process according to your service’s shutdown policy.
Where to find the next complete example
Start with the project’s examples and the package reference:
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 errorsBest 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.
- chromedp project README and examples — installation, FAQ material, allocator behavior, and links to workflows.
- chromedp package reference — exported types, functions, actions, and option details.
Use the smallest example that matches your task, then add one concern at a time: waiting, selector robustness, authentication handling, screenshots, downloads, or remote-browser lifecycle. Keep the browser and chromedp versions pinned and documented for reproducible builds.
Or skip the browser setup
If your goal is simply to obtain a clean website screenshot rather than automate a browser in Go, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; each response identifies the page verdict and billing status in X-Page-Verdict and X-Billed headers. It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients.
See the ScreenshotNeo API documentation for all options.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
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)
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}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 screenshots, and every feature is available on every plan. Create a free ScreenshotNeo account.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Is chromedp a browser or a Go library?
It is a Go client library that controls a separate Chrome-family browser through the Chrome DevTools Protocol.
Can I use chromedp without a graphical desktop?
Yes. Chrome runs headlessly by default, so a graphical desktop is not required for the normal first run.
Where are the official chromedp examples?
The project README at https://github.com/chromedp/chromedp links to the examples and the package reference.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.

