Variables
Overview
Variables in the Bruno allow you to store dynamic values that can be reused across multiple API requests, environments, and workflows. This feature enhances flexibility, maintainability, and efficiency by enabling you to manage frequently changing data points such as tokens, environment-specific URLs, or user-defined values in one place.
Types
There are 7 types of variables you can create:
- Global Environments Variables
- Environment Variables
- Collection Variables
- Folder Variables
- Request Variables
- Runtime Variables
- Prompt Variables
Additionally, Process Environment Variables can be defined in an external environment configuration file:
Variable Precedence and Scope
When a variable is accessed, the following precedence is used to determine which value is used:
- Runtime variables get the highest precedence.
- Prompt Variables are defined using the
{{?Prompt String}}syntax and hence don't compete with the above. - Process Environment Variables are accessed using the
{{process.env.VAR_NAME}}syntax and hence don't compete with the above. - Inside an environment, values can inherit from a parent. The merge is ancestor → parent → active environment, then the usual scope stack above still applies.
Variable Storage
Each variable has its own storage location either within your collection file or within the app's memory. All storage is local.
| Variable Type | Storage Location |
|---|---|
| Collection | opencollection.yml |
| Folder | folder.yml |
| Request | request.yml |
| Environment | <env-name>.yml |
| Runtime | Local storage |
| Global | Local storage |
| Prompt | Never stored |
| Process Environment | Separate .env file |
Variable Data Type
string, number, boolean, and object. Collections written with @type(...) annotations will not parse in Bruno versions older than v4.0.0.
Starting with v4.0.0, variables are no longer limited to strings. You can store any of the following types:
| Type | Example value |
|---|---|
string |
"https://api.example.com" |
number |
30 |
boolean |
true |
object |
{ "host": "localhost" } |
In .yml files, each variable is an object with a type field and a data field. In .bru files, types are stored using @number, @boolean, or @object annotations placed on the line immediately above the variable. Object values use triple-quote (''') blocks.
```yaml YAML format (.yml) runtime: variables: - name: timeout value: type: number data: "30"
- name: debug
value:
type: boolean
data: "true"
- name: config
value:
type: object
data: '{"host":"localhost","port":8080}'
- name: baseUrl
value: https://api.example.com
bru BRU format (.bru)
vars:pre-request {
@number
timeout: 30
@boolean
debug: true
@object
config: '''
{
"host": "localhost",
"port": 8080
}
'''
baseUrl: https://api.example.com
}
```
Setting typed variables from scripts
When you call bru.setEnvVar(key, value), Bruno infers the type from the value you pass and writes the correct annotation automatically:
bru.setEnvVar("timeout", 30) // written as @number
bru.setEnvVar("debug", true) // written as @boolean
bru.setEnvVar("config", { a: 1 }) // written as @object
bru.setEnvVar("baseUrl", "example.com") // written as plain string (no annotation needed)
On subsequent reads, timeout resolves as a number and config resolves as an object. It preserves the original type across runs.
Typed values work across all variable scopes: environment, global environment, collection, folder, and request variables.
Type selector in the UI
In the Vars tab you can select the type of each variable using the type dropdown next to the value field.

.bru files and environments that use plain string values continue to work without any changes or migration. The @type(...) annotation is only written when a non-string type is used.
Environment Color Coding
Bruno allows you to customize the visual appearance of your environments using color coding. This feature helps you quickly identify which environment you're currently working with, reducing the risk of accidentally running requests against the wrong environment.
Color Customization
You can assign a custom color to each environment:
- Navigate to environment settings (top right corner)
- Click the brush icon next to the environment and select a color from the color picker component
- If no color is selected, a default color will be assigned
![]()
Color-Coded Visual Indicators
Once colors are assigned, they appear in multiple places throughout the interface:
Environment Selector Dropdown: A small color swatch is displayed next to each environment name, making it easy to distinguish between environments at a glance.
Active Environment Indicator: The currently selected environment's color is prominently displayed in the environment pill in the tabs UI, providing constant visual feedback about which environment you're working with.

This visual system helps prevent mistakes when switching between development, staging, and production environments, especially in fast-paced workflows.
Debugging Variables in Console
You can access and debug variables in the console using the following pattern:
The pattern follows bru.get[Type]Var(key) where:
- [Type] is the variable type (Runtime, Request, Folder, etc.)
- key is the variable name you want to access
Example:
// Basic syntax: console.log(bru.get[Type]Var(key))
console.log(bru.getVar('myVar')) // Runtime variables
Scripting API
Please see the Scripting API for more information on how to access variables in your scripts.
Prompt variables are not accessible via the Scripting API.