# chromedp

> Drive Chrome from Go over the DevTools Protocol, with no external driver

- Category: Data & Labeling / Web Scraping & Crawling
- Language: Go
- Licence: MIT
- Repository: https://github.com/chromedp/chromedp
- Canonical page: https://ai-tldr.dev/tools/chromedp/
- Updated: 2026-11-18

## In short

chromedp is a Go package that drives browsers speaking the Chrome DevTools Protocol, such as Chrome and Chromium, with no external driver: no Node.js, Selenium or WebDriver process sits between your program and the browser. It sits in the Web Scraping & Crawling category of the Data & Labeling tools and is open-source, written in Go and licensed MIT.

## Overview

chromedp is a Go package that drives browsers speaking the Chrome DevTools Protocol, such as Chrome and Chromium, with no external driver: no Node.js, Selenium or WebDriver process sits between your program and the browser. It covers the usual browser-automation jobs — navigating pages, reading text, filling and submitting forms, running JavaScript, intercepting requests, taking screenshots and printing PDFs — from ordinary Go code. The module depends only on the Go standard library and chromedp's generated protocol package, cdproto.

The programming model is built around actions. An action is a function that runs against a browser tab; chromedp.Do runs actions that return nothing and chromedp.Run runs one action and returns its value, so reading a page title is a single call. Page events are Go iterators: chromedp.Events subscribes when it returns, so a program can subscribe, trigger the event and then range over it without missing it. Each context made with chromedp.NewContext holds a browser and a tab, and child contexts open new tabs in the same browser that are safe to use from separate goroutines.

By default chromedp starts Chrome headless and talks to it through a pipe (Chrome's --remote-debugging-pipe), so no debugging port is opened. The bundled remote package adds a websocket client for attaching to a browser that is already running, such as a container or a hosted service, and for keeping a browser open after the program exits. A visible window is one option (WithVisibleWindow, or CHROMEDP_VISIBLEWINDOW=1), and the companion termcast module streams the screen of a headless page into a terminal that can show images, even over ssh.

The project dates from 2017, when it was presented at GopherCon Singapore as a new way to drive the web from Go. Version v0.20.0 introduced the generic, iterator-based API built on typed cdproto, and the README links a migration guide listing every renamed and removed name. The companion chromedp/examples repository holds 46 single-file programs for larger tasks, and the chromedp/headless-shell Docker image provides a smaller headless build of Chrome that chromedp finds by default. It is MIT-licensed.

## What it does

- Pure Go client for the Chrome DevTools Protocol — no Node, Selenium or WebDriver, only the standard library plus cdproto
- Action-based API: chromedp.Do for side effects, chromedp.Run to return a value, chromedp.Call for any raw protocol command
- Page events as Go iterators that subscribe before you trigger them, so no event is missed
- Headless by default over a pipe; optional websocket, remote attach and keep-open via the remote package
- Tabs as contexts: child contexts open parallel tabs in one browser, safe across goroutines
- Screenshots, PDF printing, device emulation, request interception, cookies, downloads and HAR capture, each shown in the examples repository
- WithRuntimeDisabled attaches without enabling the Runtime domain, running queries in an isolated world of each frame

## Getting started

chromedp is a normal Go module; it needs Go 1.25 or newer and a Chrome or Chromium install (or the chromedp/headless-shell image). The steps below follow the project README.

1. Add the module

```bash
go get -u github.com/chromedp/chromedp
```

2. Open a page and read its title

   NewContext creates a browser context; the first action starts Chrome. Do runs actions that return nothing, Run returns a value.

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

if err := chromedp.Do(ctx, chromedp.Navigate(`https://pkg.go.dev/`)); err != nil {
	log.Fatal(err)
}
title, err := chromedp.Run(ctx, chromedp.Title())
if err != nil {
	log.Fatal(err)
}
fmt.Println(title)
```

3. Wait for a page event

   Events subscribes as soon as it returns, so you can subscribe, navigate, then read the event from the iterator.

```go
loaded := chromedp.Events(ctx, page.LoadEventFired)
if err := chromedp.Do(ctx, chromedp.Navigate(`https://pkg.go.dev/`)); err != nil {
	log.Fatal(err)
}
for ev, err := range loaded {
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(ev.Timestamp)
	break
}
```

4. Attach to a browser that is already running

   For a container or hosted browser, point the remote allocator at its websocket address and build contexts from it.

```go
allocCtx, cancel := remote.NewAllocator(context.Background(), "ws://127.0.0.1:9222/")
defer cancel()
ctx, cancel := chromedp.NewContext(allocCtx)
defer cancel()
title, err := chromedp.Run(ctx, chromedp.Title())
```

5. Run a bigger example

   Each program in chromedp/examples is one main.go; add -visible to show the browser window or -v to print the protocol messages.

```bash
go run github.com/chromedp/examples/tabs@latest
```

## When to use it

- Scraping pages that only render in a real browser, from a Go service with no Node or Selenium dependency
- Generating screenshots and PDFs of web pages in a Go backend or a headless-shell container
- End-to-end tests and form automation written in Go, with request interception and cookie control
- Giving a Go-based agent or crawler a scriptable browser, locally or attached to a remote Chrome

## Version history

- 2026-11-18 v0.24.0: Adds the WithRuntimeDisabled context option, which attaches without Runtime.enable and runs queries in an isolated world so a page cannot detect console-argument serialisation; also fixes a Poll hang inside frames.
