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

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