---
schema_version: "1"
id: 78bd6b4e6cb92380d90e03a145169e742ffea6d4aff992466423f162320ca291
title: envVar
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-system-functions-envvar.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-system-functions-envvar
source_site: docs.mulesoft.com
content_type: documentation
content_hash: c6738a914662567dcbb53f482671de89a77fd20d303be3315f49fead31390bc6
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# 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
  }
]
```
