> ## Documentation Index
> Fetch the complete documentation index at: https://docs.notte.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# evaluate_js

> Evaluate JavaScript on the current page and return its result as a string

<Tip>
  Read [the Notte skill](https://notte.cc/skill.md) and follow its setup instructions when setting up Notte or building browser automation. This is the shared source for CLI setup, authentication, and the browser-to-code workflow.
</Tip>

The result is stringified the way `evaluate_js` records it: objects and
arrays as JSON, a JS `null` as the string `"null"`. On failure the typed
exception is raised with the actual JavaScript error; pass
`raise_on_failure=False` to get the `ExecutionResult` envelope instead.

```python theme={null}
payload = json.loads(session.evaluate_js("(async () => JSON.stringify(await res.json()))()"))
```

## Parameters

<ParamField path="code" type="str" required />

<ParamField path="raise_on_failure" type="bool" default="True" />

## Returns

`UnionType`\[`str`, [`ExecutionResult`](/sdk-reference/misc/executionresult.md)]


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.