---
schema_version: "1"
id: 6fa8b3fdfc4f9a566c1fdbf81c873ea04a965cb52eaceb3acdbaea96c73fcdfb
title: envVar
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-system-functions-envvar.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-system-functions-envvar
source_site: docs.mulesoft.com
content_type: documentation
content_hash: bd402f648ec4033aee5d0a7e2d95c09e4ac6e33c7360c8a6710c94c21d7b2461
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# envVar

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## envVar(variableName: String): String | Null

Returns an environment variable with the specified name or `null` if the environment variable is not
defined.

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>variableName</code></p></td><td><p>String that provides the name of the environment variable.</p></td></tr></tbody></table>

### Example

This example returns a Mac command console (`SHELL`) path and returns `null` on `FAKE_ENV_VAR` (an
undefined environment variable). `SHELL` is one of the standard Mac environment variables. Also
notice that the `import` command enables you to call the function without prepending the module name
to it.

#### Source

```DataWeave
%dw 2.0
import * from dw::System
output application/json
---
{
    "envVars" : [
       "real" : envVar("SHELL"),
       "fake" : envVar("FAKE_ENV_VAR")
    ]
}
```

#### Output

```JSON
"envVars": [
  {
    "real": "/bin/bash"
  },
  {
    "fake": null
  }
]
```
