---
title: "Execute JavaScript in the device's Chrome browser (CDP)"
method: POST
path: "/devices/{deviceId}/browser/execute-script"
tags: ["Tools/Browser"]
---

# Execute JavaScript in the device's Chrome browser (CDP)

`POST /devices/{deviceId}/browser/execute-script`

Evaluates a JavaScript expression in the device's foreground Chrome tab via the Chrome DevTools Protocol and returns its JSON-serialized result. Devices without browser support return an unsupported-feature error.

## Path parameters

- `deviceId` string, required

## Headers

- `X-Device-Display-ID` integer

## Request body

- ExecuteScriptArgs
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `script` string, required — JavaScript expression to evaluate in the device's foreground Chrome tab (CDP Runtime.evaluate). It is an expression, not a function body — the expression's value is returned (no top-level 'return'). Must evaluate to a JSON-serializable value; wrap multi-statement logic in an IIFE, e.g. (() => { ... ; return x })().

## Response `200`

OK

- ExecuteScriptOutputBody
  - `$schema` string, uri — A URL to the JSON Schema for this object.
  - `result` unknown, required

## Other responses

- `default` — Error

## Changes

- **2026-08-01** `cd80ab1b29b0` — 1 info
  - endpoint added
- **2026-08-01** `3183ec3153d1` — 1 breaking
  - api path removed without deprecation
- **2026-07-07** `d5d1e5ee8188` — 2 info
  - api tag `Tools/Browser` added
  - api tag `Tools` removed
- **2026-06-29** `3cb3612f45e0` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/droidrun/apis/droidrun-cloud/changes/devices/:deviceId/browser/execute-script/post.md)

---

[API](https://skmtc.dev/droidrun/apis/droidrun-cloud.md) · [All operations](https://skmtc.dev/droidrun/apis/droidrun-cloud/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/droidrun/droidrun-cloud/revisions/fc388ab21a20/schema)
