# Run worker JavaScript

Node type `browser_javaScript`

## What it does

Run JavaScript in a worker to process values supplied to the node.

## Desktop client configuration

![Run worker JavaScript configuration in the desktop client](/assets/java-script.f78ec83c0a1adee00f604c3f927de88bdd1cc7cb153070292b5f8d391a9fac33.0538f3a9.webp)

Captured in the English interface of MoreLogin Desktop V2.73.101.

## Inputs

These fields belong in `data.browserUi.inputs`.

| Field | Type or values | Schema required | Execution default | Description and bounds |
|  --- | --- | --- | --- | --- |
| `params` | array<`object`> | No | `[]` | params. Editor initial value `[]` |
| `content` | `string` | No | — | Run JS script |
| `outputFormat` | `object` (supports variable references) | No | `{"type":"string"}` | Output format. Editor initial value `{"type":"string"}` |


## Mode requirements and limits

- The script runs in a terminable worker (a data processing context) and does not access the web page or the desktop client's main process. To operate on the web page, use injectJavaScript. The script text is not interpolated. Constant parameters of type object/array in params must be valid JSON objects/arrays (validated on write). The return value is validated or converted according to outputFormat. When outputFormat is omitted, {"type":"string"} is used (the same as a new node in the editor): no return value becomes null; in string format, a non-string value becomes JSON text; in number/integer format, a numeric string becomes a number; if the value cannot be converted, the node fails with OUTPUT_TYPE_MISMATCH.
- Validation code `RPA_NODE_INPUT_INVALID`


## Input references

| Field | Allowed forms |
|  --- | --- |
| `params` | `literal`, `template` |
| `content` | `literal`, `template` |
| `outputFormat` | `literal`, `template` |


## Outputs

| Output field | Type or values |
|  --- | --- |
| `value` | `["null","boolean","number","string"]` / array<`JSON`> / `object` |


Reference published fields as `${nodeId.data.field}`.

## JSON example

A complete node object for a workflow's `nodes` array or another node's `blocks`. It reads `read_title.data.text`, the output of an earlier Read element data node.

```json
{
  "id": "format_price",
  "type": "browser_javaScript",
  "data": {
    "title": "Format the price",
    "browserAction": "javaScript",
    "browserUi": {
      "inputs": {
        "params": [
          {
            "key": "price",
            "value": "${read_title.data.text}"
          }
        ],
        "content": "return 'Price: ' + params.price;",
        "outputFormat": {
          "type": "string"
        }
      },
      "exception": {
        "timeout": 30000,
        "policy": "interrupt"
      }
    }
  }
}
```

[Back to the node catalog](/browser-rpa/nodes)