---
schema_version: "1"
id: 5488c45059f76544816fe072e9b14de5d98c2ce8811a7519b815c09cc2416dfa
title: Remove Variable Transformer
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.4/remove-variable.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.4/remove-variable
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 5996685f319a52745aa1bde899a23bdb8e1ee97924564834af8f378efc56e7f3
description: MuleSoft Documentation Site
release: "4.4"
latest: false
---
---
product: Mule Runtime
version: 4.4
keywords: anypoint studio, studio, mule, variable transformer, variables, set variable, edit variable, remove variable
---

# Remove Variable Transformer

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

The Remove Variable component takes a Mule variable name and removes the variable from a Mule event.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Field</th><th>XML</th><th>Description</th></tr></thead><tbody><tr><td><p>Display Name</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Customize to display a unique name for this component in Anypoint Studio. Defaults to <code>Remove Variable</code>.</p></div></div></td></tr><tr><td><p>Name</p></td><td><p><code>variableName</code></p></td><td><div><div><p>Name of the variable to remove. If the variable does not exist in the flow, the component logs a warning (<code>WARN</code>). Attempts to access the value of a variable that does not exist return a <code>null</code> value. See <a href="#example">Example</a>.</p></div></div></td></tr></tbody></table>

## Example

This basic example shows how to remove a Mule variable from the flow:

```xml
<flow name="remove-variable-ex" >
  <scheduler doc:name="Scheduler" >
    <scheduling-strategy >
      <fixed-frequency frequency="10" timeUnit="SECONDS"/>
    </scheduling-strategy>
  </scheduler>
  <set-variable value='"value of my Mule variable"' doc:name="Set Variable"
                variableName="myMuleVar"/>
  <logger level="INFO" doc:name="Logger"
          message="#[vars.myMuleVar]"
          category="PRINT VALUE OF VARIABLE"/>
  <remove-variable doc:name="Remove Variable"
                   variableName="myMuleVar"/>
  <logger level="INFO" doc:name="Logger"
           category="ATTEMPT TO PRINT VALUE OF REMOVED VARIABLE"
           message="#[vars.myMuleVar]"/>
  <remove-variable doc:name="Remove Variable"
                   variableName="banana"/>
</flow>
```

The flow uses the following processors:

- The Scheduler component triggers the flow.

- Set Variable creates a Mule variable (`myMuleVar`).

- The first Logger in the flow prints the value of the variable (`"value of my Mule variable"`).

- Remove Variable provides a string with the name of the variable (`variableName="myMuleVar"`) to
  remove the variable from the Mule event.

- The second Logger prints `null` because the Mule variable no longer exists.

- The second Remove Variable logs a `WARN` message because it attempts to remove a Mule variable
  (`banana`) that does not exist in the Mule event.

The following example shows the logs for an execution of this flow:

```logs
INFO  2022-12-15 08:33:20,151 ...event: 2f65e920-7c96-11ed-97ec-147ddaaf4f97]
PRINT VALUE OF VARIABLE: "value of my Mule variable"

INFO  2022-12-15 08:33:20,155 ...event: 2f65e920-7c96-11ed-97ec-147ddaaf4f97]
ATTEMPT TO PRINT VALUE OF REMOVED VARIABLE: null

WARN  2022-12-15 08:33:20,156 ...event: 2f65e920-7c96-11ed-97ec-147ddaaf4f97]
...RemoveFlowVariableProcessor: There is no variable named 'banana'.
Check the 'variableName' parameter in the 'remove-variable' component at
remove-variable-ex/processors/4
```

## See Also

- [Variables in Mule Events](https://docs.mulesoft.com/mule-runtime/4.4/about-mule-variables)

- [Enrich Data with Target Variables](https://docs.mulesoft.com/mule-runtime/4.4/target-variables)
