Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cdp

> DevOps
Open source

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.

794 stars0 likes0 views
WebsiteGitHub

About

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language.

cdp

Coverage Status Go Report Card GoDoc

Package cdp provides type-safe bindings for the Chrome DevTools Protocol (CDP), written in the Go programming language. The bindings are generated (by cdpgen) from the latest tip-of-tree (tot) protocol definitions and are mainly intended for use with Google Chrome or Chromium, however, they can be used with any debug target (Node.js, Edge DevTools Protocol, Safari, etc.) that implement the protocol.

This package can be used for any kind of browser automation, scripting or debugging via the Chrome DevTools Protocol.

A big motivation for cdp is to expose the full functionality of the Chrome DevTools Protocol and provide it in a discoverable and self-documenting manner.

Providing high-level browser automation is a non-goal for this project. That being said, cdp hopes to improve the ergonomics of working with the protocol by providing primitives better suited for Go and automating repetitive tasks.

Features

  • Discoverable API for the Chrome DevTools Protocol (GoDoc, autocomplete friendly)
  • Contexts as a first-class citizen (for timeouts and cancellation)
  • Simple and synchronous event handling (no callbacks)
  • Concurrently safe
  • No silent or hidden errors
  • Do what the user expects
  • Match CDP types to Go types wherever possible
  • Separation of concerns (avoid mixing CDP and RPC)

Installation

bash
$ go get -u github.com/mafredri/cdp

Documentation

See API documentation for package, API descriptions and examples. Examples can also be found in this repository, see the simple, advanced, logging and incognito examples.

Usage

The main packages are cdp and rpcc, the former provides the CDP bindings and the latter handles the RPC communication with the debugging target.

To connect to a debug target, a WebSocket debugger URL is needed. For example, if Chrome is running with --remote-debugging-port=9222 the debugger URL can be found at localhost:9222/json. The devtool package can also be used to query the DevTools JSON API (see example below).

Here is an example of using cdp:

…

For more information, consult the documentation.

Acknowledgements

The Go implementation of gRPC (grpc-go) has been a source of inspiration for some of the design decisions made in the cdp and rpcc packages. Some ideas have also been borrowed from the net/rpc package from the standard library.

Resources

  • Chrome DevTools Protocol
    • Viewer (latest tip-of-tree) official protocol API docs
    • Repository (GitHub) please file issues at this repo if you have concerns or problems with the Chrome DevTools Protocol
    • Mailing list
  • Getting Started with Headless Chrome
  • Awesome chrome-devtools: Chrome DevTools Protocol
  • RemoteDebug is an initiative to bring remote debugging (e.g. CDP) to all modern browsers
    • Protocol Compatibility Tables

Issues· 14 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Gocdpchrome-debugging-protocolchrome-devtools-protocoldebugging

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理