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

# envVar

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

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