Extension DevTools APIs, Side Panel, and Debugger Protocol
How Chrome extension DevTools pages, side panels, and the debugger API work: manifest setup, panels, inspectedWindow, and CDP limits.
This page summarises Chrome Extensions documentation on three related ways to give an extension deep access to browsing: DevTools extensions (custom panels and hooks inside Developer Tools), the Side Panel API (persistent UI beside the page), and the browser.debugger API (Chrome DevTools Protocol from a service worker). All three solve different problems; choosing the wrong one leads to manifest errors, missing APIs, or a disruptive debugging banner.
DevTools extensions vs browser.debugger: when to use which
Section titled “DevTools extensions vs browser.debugger: when to use which”A DevTools extension adds UI and logic inside the DevTools window through a dedicated DevTools page and the browser.devtools.* namespace. A browser.debugger attachment drives the same remote debugging protocol DevTools uses, but from extension code (typically a service worker), without building a DevTools panel.
DevTools extensions add functionality to Chrome DevTools by accessing DevTools-specific extension APIs through a DevTools page added to the extension.
— Chrome, Extend DevTools
The browser.debugger API gives extensions the ability to interact with the Chrome Devtools Protocol. This is the same protocol that is used for Chrome’s Devtools, and an amazing number of other tools.
— Chrome, Deal with remote hosted code violations
| Approach | Primary APIs | User-visible effect | Typical use |
|---|---|---|---|
| DevTools extension | devtools.panels, devtools.inspectedWindow, devtools.network, devtools.recorder, devtools.performance |
New DevTools tab or sidebar pane | Framework inspectors, network aids, custom auditing UI |
browser.debugger |
browser.debugger.attach, sendCommand, onEvent |
Warning bar: extension is debugging the browser | Automation, deep CDP scripting, protocol-level control |
| Side panel (separate UI surface) | browser.sidePanel |
Panel beside the page, not inside DevTools | Dictionaries, notes, tools that follow browsing |
For most “inspect this page and show custom UI” tasks, a DevTools extension is the intended path. Reserve browser.debugger for protocol-level work that truly needs CDP outside DevTools, and accept the banner and permission implications.
DevTools extension architecture and devtools_page manifest key
Section titled “DevTools extension architecture and devtools_page manifest key”A DevTools extension is a normal extension plus a DevTools page: an HTML entry loaded once per open DevTools window, with access to browser.devtools.* (and, in current docs, broader extension APIs from that page).
When a DevTools window opens, a DevTools extension creates an instance of its DevTools page that exists as long as the window is open. This page has access to the DevTools APIs and extension APIs, and can do the following: Create and interact with panels using the devtools.panels APIs… Get information about the inspected window and evaluate code in the inspected window using the devtools.inspectedWindow APIs. Get information about network requests using the devtools.network APIs. Extend the Recorder panel using the devtools.recorder APIs. Get information about the recording status of the Performance panel using the devtools.performance APIs.
— Chrome, Extend DevTools
How to declare devtools_page in the manifest
Section titled “How to declare devtools_page in the manifest”Add devtools_page pointing at a local HTML file (not a bare script file).
{ "name": "My extension", "version": "1.0", "devtools_page": "devtools.html"}The
devtools_pagefield must point to an HTML page. Because the DevTools page must be local to your extension, we recommend specifying it using a relative URL. The members of thebrowser.devtoolsAPI are available only to the pages loaded within the DevTools window while that window is open. Content scripts and other extension pages don’t have access to these APIs.— Chrome, Extend DevTools
Each API under DevTools also expects devtools_page in the manifest; see for example browser.devtools.inspectedWindow and browser.devtools.network.
Messaging: DevTools page, service worker, and content scripts
Section titled “Messaging: DevTools page, service worker, and content scripts”DevTools pages often need browser.tabs.* or injection APIs that are awkward to call from the DevTools context alone.
The
tabIdproperty provides the tab identifier that you can use with thebrowser.tabs.*API calls. However,browser.tabs.*API is not exposed to the Developer Tools extension pages due to security considerations—you will need to pass the tab ID to the background page and invoke thebrowser.tabs.*API functions from there.— Chrome, browser.devtools.inspectedWindow
The recommended pattern on Manifest V3 is to inject with browser.scripting.executeScript from the DevTools page using browser.devtools.inspectedWindow.tabId; see Extend DevTools — Inject a content script. To detect whether any DevTools window is open, the DevTools page can browser.runtime.connect to the service worker and count connect/disconnect events (Extend DevTools — Detect when DevTools opens and closes).
devtools.panels: custom DevTools tabs and sidebar panes
Section titled “devtools.panels: custom DevTools tabs and sidebar panes”browser.devtools.panels integrates extension UI into the DevTools window: a panel is a top-level tab (like Elements or Network); a sidebar pane is supplementary UI tied to an existing panel.
Use the
browser.devtools.panelsAPI to integrate your extension into Developer Tools window UI: create your own panels, access existing panels, and add sidebars.— Chrome, browser.devtools.panels
How to create a custom DevTools panel tab
Section titled “How to create a custom DevTools panel tab”browser.devtools.panels.create("Font Picker", "FontPicker.png", "Panel.html", function(panel) { /* ... */ });Panel and sidebar documents are extension HTML pages with the same API access as the DevTools page. Optional handlers include setOpenResourceHandler (at most one effective handler; last registration wins) and openResource to jump DevTools to a URL and line — see browser.devtools.panels.
How to add a sidebar pane on the Elements panel
Section titled “How to add a sidebar pane on the Elements panel”browser.devtools.panels.elements.createSidebarPane("Font Properties", function(sidebar) { sidebar.setPage("Sidebar.html"); sidebar.setHeight("8ex"); });Sidebar content can be:
- HTML —
setPage(path) - JSON —
setObject(jsonObject)(JSON-compliant objects only) - Live page values —
setExpression(expression)(DOM nodes and arbitrary objects; evaluated in the inspected page)
For both
setObject()andsetExpression(), the pane displays the value as it would appear in the DevTools console. However,setExpression()lets you display DOM elements and arbitrary JavaScript objects, whilesetObject()only supports JSON objects.— Chrome, Extend DevTools
The Recorder extension surface uses devtools.recorder with title and pagePath parameters (browser.devtools.recorder). Performance integrations listen for recording status via browser.devtools.performance.
devtools.inspectedWindow: eval, reload, and resources
Section titled “devtools.inspectedWindow: eval, reload, and resources”browser.devtools.inspectedWindow is the main bridge to the page under inspection: tab ID, evaluation, reload, and resource listing/editing.
Use the
browser.devtools.inspectedWindowAPI to interact with the inspected window: obtain the tab ID for the inspected page, evaluate the code in the context of the inspected window, reload the page, or obtain the list of resources within the page.— Chrome, browser.devtools.inspectedWindow
inspectedWindow.eval() vs scripting.executeScript()
Section titled “inspectedWindow.eval() vs scripting.executeScript()”eval() runs in the inspected page’s JavaScript world (by default the main frame), with the same execution context as the DevTools console—including Console Utilities such as $0 and inspect().
Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown.
— Chrome, browser.devtools.inspectedWindow
Caution: Use
eval()only if you need access to the JavaScript content of an inspected page. Otherwise, we recommend using thebrowser.scripting.executeScript()method to run scripts.— Chrome, Extend DevTools
Useful eval() options:
| Option | Effect |
|---|---|
frameURL |
Evaluate in the iframe whose URL matches |
useContentScriptContext: true |
Evaluate in your extension’s content-script context (requires the script already injected; otherwise E_NOTFOUND) |
scriptExecutionContext |
Target a content-script context for a specific origin (Chrome 107+) |
To pass the selected element to a content script, expose a function in the content script and call browser.devtools.inspectedWindow.eval("setSelectedElement($0)", { useContentScriptContext: true }) as described in Extend DevTools.
reload() options for cache, user agent, and early injection
Section titled “reload() options for cache, user agent, and early injection”browser.devtools.inspectedWindow.reload() accepts ignoreCache (hard reload before load), userAgent (header and navigator.userAgent), and injectedScript (runs once per reload call path—not on every ordinary user reload). Details are in browser.devtools.inspectedWindow.
devtools.network: observe finished requests
Section titled “devtools.network: observe finished requests”browser.devtools.network exposes request lifecycle events to DevTools pages. The manifest still requires devtools_page.
The documented pattern combines network events with inspectedWindow.eval to log into the page console—for example, flagging large images on onRequestFinished (browser.devtools.network).
browser.debugger: CDP transport, permissions, and limits
Section titled “browser.debugger: CDP transport, permissions, and limits”browser.debugger is an alternate transport for Chrome’s remote debugging protocol: attach by tab, send CDP commands, receive events.
The
chrome.debuggerAPI serves as an alternate transport for Chrome’s remote debugging protocol. Usechrome.debuggerto attach to one or more tabs to instrument network interaction, debug JavaScript, mutate the DOM and CSS, and more. Use the Debuggee propertytabIdto target tabs withsendCommandand route events bytabIdfromonEventcallbacks.— Chrome, browser.debugger
Manifest permission debugger
Section titled “Manifest permission debugger”Declare the debugger permission in manifest.json (browser.debugger — Permissions).
Enterprise policy and blocked hosts
Section titled “Enterprise policy and blocked hosts”Enterprise ExtensionSettings can block hosts via runtime_blocked_hosts unless allowed in runtime_allowed_hosts. Attach fails with “This page cannot be scripted due to an ExtensionsSettings policy.” when a blocked URL is targeted; navigation to a blocked host detaches the debugger (browser.debugger).
Allowed CDP domains
Section titled “Allowed CDP domains”Not every CDP domain is exposed. Allowed domains include Accessibility, Audits, CacheStorage, Console, CSS, Database, Debugger, DOM, DOMDebugger, DOMSnapshot, Emulation, Fetch, IO, Input, Inspector, Log, Network, Overlay, Page, Performance, Runtime, Storage, Target, Tracing, WebAudio, and WebAuthn (browser.debugger).
Flat sessions and child targets (Chrome 125+)
Section titled “Flat sessions and child targets (Chrome 125+)”For out-of-process iframes and workers, listen for Target.attachedToTarget, build a child session with sessionId, and enable flat auto-attach via Target.setAutoAttach with flatten: true. Auto-attach is not fully recursive across deep cross-origin frame chains—you may need Target.setAutoAttach per intermediate frame (browser.debugger — Attach to related targets).
Side Panel API: UI beside the page (not inside DevTools)
Section titled “Side Panel API: UI beside the page (not inside DevTools)”The Side Panel API hosts extension UI in the browser chrome next to web content—distinct from DevTools panels. Overview and UX notes appear in browser.sidePanel, Create a side panel, and User interface components.
Use the
browser.sidePanelAPI to host content in the browser’s side panel alongside the main content of a webpage.— Chrome, browser.sidePanel
The Side Panel API allows extensions to display their own UI in the side panel, enabling persistent experiences that complement the user’s browsing journey.
— Chrome, browser.sidePanel
Add "sidePanel" permission and optionally a default panel path:
{ "side_panel": { "default_path": "sidepanel.html" }, "permissions": ["sidePanel"]}See Manifest file format for a full minimal example.
Global default panel vs tab-specific side panel
Section titled “Global default panel vs tab-specific side panel”- Every site — set
side_panel.default_pathin the manifest (browser.sidePanel). - Specific sites — call
browser.sidePanel.setOptions({ tabId, path, enabled })from a service worker (e.g. onbrowser.tabs.onUpdated). When the user switches to a tab where the panel is disabled, the panel hides; it reappears when returning to an enabled tab (browser.sidePanel).
Opening the side panel on user gesture
Section titled “Opening the side panel on user gesture”browser.sidePanel.setPanelBehavior({ openPanelOnActionClick: true })ties opening to the action toolbar icon (requiresactionin the manifest).browser.sidePanel.open({ windowId })oropen({ tabId })must run in response to a user action (action click, context menu, shortcut, or gesture on an extension or content-script page) (browser.sidePanel).
Events onOpened and onClosed (Chrome 141+/142+) let you react to panel visibility (browser.sidePanel).
Common mistakes
Section titled “Common mistakes”- Calling
browser.devtools.*from a content script or popup — Those APIs exist only on pages loaded inside an open DevTools window (Extend DevTools). - Using
tabs.*directly from a DevTools page — ForwardinspectedWindow.tabIdto the service worker (browser.devtools.inspectedWindow). - Defaulting to
debuggerfor page scripting — Preferscripting.executeScriptor DevTools APIs;debuggershows the global debugging banner (Deal with remote hosted code violations). eval()without JSON-serialisable results — Non-JSON results throw; use expressions that return JSON-safe values or handle exceptions (browser.devtools.inspectedWindow).sidePanel.open()without a user gesture — The call is rejected outside an allowed user action (browser.sidePanel).- Expecting recursive iframe attach with one
setAutoAttach— Nested cross-origin chains need auto-attach at each level (browser.debugger).
How to check this on your site
Section titled “How to check this on your site”-
Load your extension unpacked from
chrome://extensions, confirmdevtools_page,side_panel, andpermissionsmatch Manifest file format and the relevant API references (browser.devtools.panels, browser.sidePanel, browser.debugger). -
Open a test tab, launch DevTools, and verify your panel or sidebar appears per Extend DevTools; exercise
inspectedWindow.evaland, if used,devtools.networklisteners. -
For a side panel, confirm default or tab-specific behaviour using
setOptionsand open the panel via action click orsidePanel.openafter a user gesture, following Create a side panel. -
If you use
browser.debugger, attach to a tab, confirm CDP commands stay within allowed domains, and confirm the debugging banner behaviour described in Deal with remote hosted code violations. -
You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are questioning so it can be corrected.