*** title: Add script runner blocks to your notebook approved: 2026-02-20T00:00:00.000Z slug: >- docs/postman-api-network/showcase/publish/notebooks/draft/add-script-runner-blocks max-toc-depth: 2 ux: v12 ------- Write JavaScript code in your notebook to create an interactive experience. For example, you can add a script runner block that generates a random number and use that number in a [request block](/docs/postman-api-network/showcase/publish/notebooks/draft/add-request-blocks/) that accepts one. In addition, you can [import external libraries](/docs/tests-and-scripts/write-scripts/packages/external-package-registries/) and [visualize your data](/docs/tests-and-scripts/write-scripts/postman-sandbox-reference/pm-visualizer/). You can also reference a script runner block's output elsewhere in your notebook. ## Add a script runner block To add a script runner block, do the following: 1. Open your notebook or [create a new one](https://www.postman.com/notebook/new). 2. Place your cursor where you want to add the script runner block. Then, enter a forward slash ("/"). Postman displays a block menu. 3. Choose Run icon **Script Runner**. 4. Name your script runner block. 5. Write your code. 6. Click **Run**. Postman runs the code and returns the result. To see the logs, open the **Logs** tab. ## Reference your script runner block Reference your script runner block by name. For example, if you name your script runner block "randomNumbers", you can reference its output with the syntax `{{randomNumbers}}` in text, an [input block](/docs/postman-api-network/showcase/publish/notebooks/draft/add-input-blocks/), a [request block](/docs/postman-api-network/showcase/publish/notebooks/draft/add-request-blocks/), or an [AI request block](/docs/postman-api-network/showcase/publish/notebooks/draft/add-ai-request-blocks/). Or you can reference it with the syntax `$randomNumbers` in another script runner block. Furthermore, you can use dot notation to reference data within the output. For example, in a request block, you can reference the first random number with the syntax `{{randomNumbers.0}}`. Or in another script runner block, you can reference the same value with the syntax `$randomNumbers[0]`. To reference your script runner block, do the following: 1. Open your notebook or [create a new one](https://www.postman.com/notebook/new). 2. Get your script runner block's name. 3. Reference your script runner block: * To reference your script runner block in text, an input block, a request block, or an AI request block, use the syntax `{{scriptRunnerBlockName}}` or `{{scriptRunnerBlockName.path.to.data}}`. * To reference your script runner block in another script runner block, use the syntax `$scriptRunnerBlockName` or `$scriptRunnerBlockName.path.to.data`.