*** title: Add script runner blocks to your notebook updated: 2025-12-02T00:00:00.000Z slug: >- docs/postman-api-network/showcase/publish/notebooks/draft/add-code-runner-blocks max-toc-depth: 2 ---------------- You can write JavaScript code and reference its output elsewhere 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. You can also [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/). ## 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, type 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 icon **Run**. Postman runs the code and returns the result. To see the logs, open the **Logs** tab. ## Reference your script runner block {/* vale Vale.Spelling = NO */} {/* "randomNumber" is a variable name. */} You can reference your script runner block by name. For example, if you name your script runner block "randomNumber", you can reference its output in a [request block](/docs/postman-api-network/showcase/publish/notebooks/draft/add-request-blocks/) with the syntax `{{randomNumber}}`. Or you can reference it in another script runner block with the syntax `$randomNumber`. {/* vale Vale.Spelling = YES */} 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 an input or request block, use the syntax `{{scriptRunnerName}}`. * To reference your script runner block in another script runner block, use the syntax `$scriptRunnerName`.