# User-Defined Variables

The Variables section is a key-value storage for storing and reusing some data. It is often used for removing code duplicates and improving readability: the greetingUrl variable says more than just the line <https://next.json-generator.com/api/json/get/EJvQVEVGL> for sure.

The variables mechanism is very well integrated to all application parts and has several features:

* You can use strings, objects, arrays, and links to other variables as values.
* Variables are defined for each node and are inherited from parent nodes.
* Variables values can refer to other variables.
* [Default variables](https://docs.testmace.com/master/variables/variables) names start with $.

### Using Variables

You can use variables in any string parameters of the node - URLs, headers names, authorization tokens, etc. To do that, use the `${variableName}` syntax, where `variableName` is a link to the variable. Here are some examples:

* `${id}`
* `${$dynamicVar.id}`
* `${$response.body.name}`

It's possible to combine strings and links to other variables in the node parameters fields. For instance, you can use  `http://${host}/posts/${$dynamicVar.id}` as an URL.&#x20;

To access an array element, that is stored in a variable, you can use the `${variableName[index]}` syntax. For example, to access the third response entity id, you'll write `${$response.body[2].id}`. Note that it the index is zero-based.

Autocompletion works for variables:

![Variables autocompletion](https://1914040845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LYfhIaTTw23Sf3L5jfe%2F-LgbIUKFExtTnLYtXZVP%2F-LgbNeBxeiKn0jQ0n6-X%2F7.gif?alt=media\&token=cd9aa811-9a11-488c-9c52-676c577ccc80)

Variable value highlighting works as well:

![Variable value highlighting](https://1914040845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LYfhIaTTw23Sf3L5jfe%2F-LgbIUKFExtTnLYtXZVP%2F-LgbO0UDKSouje5vnu0f%2F7.png?alt=media\&token=878cba16-caf1-4847-a757-8c3f0a0d943a)

There is the Variables button in every node interface, that opens the variables dialog. This is how the button looks like:

![The button to open the variables dialog](https://1914040845-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LYfhIaTTw23Sf3L5jfe%2F-LgXQ94dC-kuYXsYS_fy%2F-LgXRS7WppaA8EhJwsVI%2F7.png?alt=media\&token=285448ac-d72a-4ab1-aafe-95ed7735c6a8)

The button looks the same for all node types. You'll learn more about how to work with variables in the next sections.
