---
schema_version: "1"
id: b1c2e45f1815cbb74a6a14592f12d1b4ee58f13bb9b4953d3e7e1c22d3ee75ad
title: Remove Variable (<remove-variable/>)
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/anypoint-code-builder/acb-component-remove-variable.md
canonical_url: https://docs.mulesoft.com/anypoint-code-builder/acb-component-remove-variable
source_site: docs.mulesoft.com
content_type: documentation
content_hash: b8739cb14ee674c01a61227177858af0ecaa49c94175cc1354a6d05c95cc5f45
description: MuleSoft Documentation Site
latest: true
---
---
product: Anypoint Code Builder
version: master
---

# Remove Variable (<remove-variable/>)

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

Removes a Mule variable from a Mule event.

## Component XML

This component supports the following XML structure:

```xml
<remove-variable
  doc:name="Remove Variable"
  variableName="myMuleVar" />
```

Remove Variable (`<remove-variable/>`) attributes are configurable through the UI and XML.

<table><colgroup><col> <col> <col></colgroup><thead><tr><th>Attribute Name</th><th>Attribute XML</th><th>Description</th></tr></thead><tbody><tr><td><p><strong>Remove variable</strong> (default)</p></td><td><p><code>doc:name</code></p></td><td><div><div><p>Editable name for the component to display in the canvas.</p></div></div></td></tr><tr><td><p>N/A</p></td><td><p><code>doc:id</code></p></td><td><div><div><p>Automatically generated identifier for the component.</p></div></div></td></tr><tr><td><p><strong>Variable name</strong></p></td><td><p><code>variableName</code></p></td><td><div><div><p>Name of the Mule variable to remove.</p></div></div></td></tr></tbody></table>

## Examples

The following example shows how to remove a Mule variable from the flow:

```xml
<flow name="remove-variable-ex" >
  <scheduler doc:name="Scheduler" > (1)
    <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"/> (2)
  <logger level="INFO" doc:name="Logger"
          message="#[vars.myMuleVar]"
          category="PRINT VALUE OF VARIABLE"/> (3)
  <remove-variable doc:name="Remove Variable"
                   variableName="myMuleVar"/> (4)
  <logger level="INFO" doc:name="Logger"
           category="ATTEMPT TO PRINT VALUE OF REMOVED VARIABLE"
           message="#[vars.myMuleVar]"/> (5)
  <remove-variable doc:name="Remove Variable"
                   variableName="banana"/> (6)
</flow>
```

<table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>The Scheduler component triggers the flow.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>Set Variable creates a Mule variable (<code>myMuleVar</code>).</td></tr><tr><td><i data-value="3"></i><b>3</b></td><td>The first Logger in the flow prints the value of the variable (<code>"value of my Mule variable"</code>).</td></tr><tr><td><i data-value="4"></i><b>4</b></td><td>Remove Variable provides a string with the name of the variable (<code>variableName="myMuleVar"</code>) to remove the variable from the Mule event.</td></tr><tr><td><i data-value="5"></i><b>5</b></td><td>The second Logger prints <code>null</code> because the Mule variable no longer exists.</td></tr><tr><td><i data-value="6"></i><b>6</b></td><td>The second Remove Variable logs a <code>WARN</code> message because it attempts to remove a Mule variable (<code>banana</code>) that does not exist in the Mule event.</td></tr></tbody></table>

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/latest/about-mule-variables)

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