Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
chromedp is a Go package for automating Chrome-family browsers through the Chrome DevTools Protocol (CDP). Add it to a Go module, make a Chrome or Chromium executable available to your program, then use a chromedp context and actions to control the browser. The first run is headless by default, so a successful capture or navigation may happen without a visible window.
What chromedp does
chromedp lets a Go program drive browsers that support the Chrome DevTools Protocol. That makes it useful when a task needs a real browser—for example, browser testing, page inspection, scraping, or profiling—rather than just an HTTP request. The project describes it as a high-level client; its README and package reference are the best starting points for the API and more workflows: chromedp project README and chromedp package reference.
It is a library, not a desktop application with its own installer. Your Go program imports the package, and a browser executable must be available to that program or reachable as an existing browser instance. The project’s README discusses both starting Chrome and connecting to an existing instance. The sources cited here do not establish a current Go, chromedp, and browser compatibility matrix, so verify versions against the project and environment you choose rather than assuming every combination is supported.
Add chromedp to a Go project
Create or enter a module
In a new project directory, initialize a Go module. Replace the example module path with one appropriate for your project:
#1 Best Overall
go mod init example.com/chromedp-demo
If the directory is already a module, skip initialization and run dependency commands from its root. The chromedp README documents this installation command:
go get -u github.com/chromedp/chromedp
This is the command documented by the project, not a claim that it is the newest preferred dependency-management choice for every Go module. Review the resulting module changes and use the dependency version your project intends to maintain.
Check the browser prerequisite
Before running your program, confirm that Chrome or Chromium is installed and available to the process. A browser installed on your workstation may not be available in a separate container, service account, or deployment environment. chromedp needs to start a browser or connect to an existing instance; installing the Go package alone does not provide a visible browser application.
Run a minimal Go program
This example opens a page and prints its document title. Save it as main.go in the module directory after adding the dependency:
package main
import (
"context"
"fmt"
"log"
"github.com/chromedp/chromedp"
)
func main() {
ctx, cancel := chromedp.NewContext(context.Background())
defer cancel()
var title string
err := chromedp.Run(ctx,
chromedp.Navigate("https://example.com"),
chromedp.Title(&title),
)
if err != nil {
log.Fatal(err)
}
fmt.Println(title)
}
Run it from the module root with:
go run .
The important pieces are the context, the ordered actions passed to chromedp.Run, and the error check. Navigate requests a page load; Title reads the title into a Go variable. This small example is deliberately limited to one navigation and one value. For interactions or more involved workflows, use the project’s examples and API reference instead of guessing action names or behavior.
Understand headless mode and browser visibility
By default, Chrome runs headlessly, according to the chromedp README. That means the browser can navigate and perform actions without opening a window on your desktop. No visible window is not, by itself, evidence that the program failed; check the returned error and output first.
For debugging that requires a visible browser, the README points to DefaultExecAllocatorOptions as the place to change the default behavior. Consult the current README and package reference for the applicable options for your dependency version. Avoid copying an option from an old snippet without checking that it matches the version in your module.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Contexts, cancellation, and browser cleanup
Contexts define the lifetime of chromedp work. In the example, NewContext creates the context used for browser actions, and defer cancel() ensures that the program cancels it when main returns. In a larger program, decide which operation owns the context and cancel it when that operation is finished or no longer needed.
The project README notes that context canceled can surface when the context is canceled or when the browser connection is lost. Treat it as a lifecycle or connection clue, not as proof of one single failure. Check whether application code canceled the context early, whether the browser process is still running, and whether the connection to an existing browser was interrupted.
Rank #4
Linux process cleanup
The README says chromedp force-kills Chrome child processes it started on Linux to avoid resource leaks. If your deployment needs a long-running Chrome process, the README documents manually starting Chrome and using RemoteAllocator to connect. Follow the README’s instructions for that setup; the consulted sources do not establish a universal command line or configuration that applies to every browser version and environment.
Where to go after the first run
Use the package reference when you need to check a symbol or its documented API. Use the project README and examples when you need a complete workflow, headless-mode adjustment, or guidance for connecting to an existing browser. For a real project, test the exact Go, chromedp, and browser versions together in the environment where the program will run; the cited project materials do not provide a current compatibility matrix.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Troubleshooting a first run
The program says it cannot find or start Chrome
Check that a Chrome or Chromium executable is installed and available to the account and environment running the Go program. A browser present on a developer’s desktop is not automatically available to a process running elsewhere. If your intention is to use an existing browser rather than have chromedp start one, follow the README’s documented existing-instance and RemoteAllocator guidance.
Best Value
No browser window appears
Headless operation is the default. Confirm whether the program completed and inspect its output and error before changing settings. If you need to observe the browser, consult the README’s guidance on DefaultExecAllocatorOptions for your package version.
You receive context canceled
Check for an early call to the context’s cancel function and for browser termination or a lost connection. The README identifies both context cancellation and browser connection loss as possible sources of this error. Keep the relevant context alive for the duration of the actions that use it.
Installation or example code does not match your project
Check the dependency version recorded in your module and consult the matching package reference. The project’s documented go get -u command is an installation instruction, not a guarantee that every version combination has identical APIs or browser behavior. The sources cited here do not establish a compatibility matrix, so don’t infer one from a successful build on a different machine.
Recommended Free Tools
Or skip the browser setup
If your job is to get a screenshot or PDF from a URL rather than automate a browser workflow in Go, ScreenshotNeo provides a website screenshot API and MCP server. A single request can return PNG, JPEG, WebP, or PDF. For example, this cURL request saves a WebP screenshot of a page:
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options and response details. ScreenshotNeo removes cookie banners, popups, and chat widgets before the shot; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots, and the free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up free for ScreenshotNeo.
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.

