clears values and definitions for the symbols si.


clears values and definitions for all symbols whose names textually match any of the arbitrary string patterns patti.


clears values and definitions for any symbols that are equal to or whose names match any of the speci.


  • Clear does not clear attributes, defaults, options or messages associated with symbols. »
  • The pattern patt can be given as a string with metacharacters, as StringExpression[] or as RegularExpression["regex"]. »
  • Clear allows abbreviated string patterns containing the following metacharacters:
  • *zero or more characters
    @one or more characters, excluding uppercase letters
  • Clear["context`*"] clears all symbols in a particular context. »
  • Clear["`*"] clears all symbols in the current context. »
  • Clear does not affect symbols with the attribute Protected. »
  • Clear has attribute HoldAll. »


open allclose all

Basic Examples  (2)

Clear a variable:

The variable no longer has a value:

Define values for a symbol:

Clear values:

Scope  (12)

Symbol Inputs  (7)

Clear values of variables (ownvalues):

Clear functions (downvalues):

Clear upvalues:

Clear subvalues:

Clear formatting:

Clear several symbols:

Use a combination of symbols and symbol names:

Only x3 remains defined:

Using Patterns  (5)

Specify symbols to clear as string patterns:

Clear all symbols in the current context:

Clear all symbols in a given context:

Clear all 2-character symbols in the current context using StringExpression:

The symbols x1 and x2 were cleared, but y remains unaffected:

Clear all 3-character symbols in the current context using RegularExpression:

Applications  (2)

Clear any old definitions before making new ones:

Unprotect and clear all symbols in a package, to allow it to be read twice:

Properties & Relations  (6)

Clear[pattern] clears the same symbols as Clear/@Names[pattern]:

Use Unset (=.) to clear definitions with a particular left-hand side:

Clear all definitions:

Clear does not remove attributes, defaults or options:

Use ClearAll to clear everything:

Clear does not remove messages:

Use ClearAll to clear messages:

Clear removes all definitions but leaves the symbol intact:

Remove removes the symbol completely:

Clear has the attribute HoldAll:

This clears symbol itself:

This clears its value:

Possible Issues  (2)

Protected symbols cannot be cleared:

Use Unprotect to clear definitions of protected symbols:

When using a pattern without a context mark, all matching symbols on $ContextPath are cleared:

The symbol xy was cleared, along with attempts to clear several system symbols:

Use a pattern with an explicit context mark to avoid potentially matching symbols from system or other contexts:

Wolfram Research (1988), Clear, Wolfram Language function, (updated 2022).


Wolfram Research (1988), Clear, Wolfram Language function, (updated 2022).


Wolfram Language. 1988. "Clear." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022.


Wolfram Language. (1988). Clear. Wolfram Language & System Documentation Center. Retrieved from


@misc{reference.wolfram_2024_clear, author="Wolfram Research", title="{Clear}", year="2022", howpublished="\url{}", note=[Accessed: 24-June-2024 ]}


@online{reference.wolfram_2024_clear, organization={Wolfram Research}, title={Clear}, year={2022}, url={}, note=[Accessed: 24-June-2024 ]}