ClearAll
clears all values, definitions, attributes, defaults, options and messages for the symbols si.
clears all symbols whose names textually match any of the arbitrary string patterns patti.
clears any symbols that are equal to or whose names match any of the speci.
Details

- The pattern patt can be given as a string with metacharacters, as StringExpression[…] or as RegularExpression["regex"]. »
- ClearAll allows abbreviated string patterns containing the following metacharacters:
-
* zero or more characters @ one or more characters, excluding uppercase letters - ClearAll["context`*"] clears all symbols in a particular context. »
- ClearAll["`*"] clears all symbols in the current context. »
- ClearAll does not affect symbols with the attributes Locked or Protected. »
- ClearAll has attribute HoldAll. »
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Scope (16)Survey of the scope of standard use cases
Symbol Inputs (11)
Clear values of variables (ownvalues):

https://wolfram.com/xid/0tzqi180-cdnu4f

https://wolfram.com/xid/0tzqi180-escexy


https://wolfram.com/xid/0tzqi180-c2li30

https://wolfram.com/xid/0tzqi180-5u4ym


https://wolfram.com/xid/0tzqi180-c9dse6

https://wolfram.com/xid/0tzqi180-ky6hnz


https://wolfram.com/xid/0tzqi180-gfghut

https://wolfram.com/xid/0tzqi180-krgpda


https://wolfram.com/xid/0tzqi180-gkvbc1

https://wolfram.com/xid/0tzqi180-qq42u0


https://wolfram.com/xid/0tzqi180-dm4hnz

https://wolfram.com/xid/0tzqi180-24p5o


https://wolfram.com/xid/0tzqi180-dqc9p4

https://wolfram.com/xid/0tzqi180-dh80v3


https://wolfram.com/xid/0tzqi180-b23v3h

https://wolfram.com/xid/0tzqi180-u1j0yk


https://wolfram.com/xid/0tzqi180-vial91

https://wolfram.com/xid/0tzqi180-xn9q7u


https://wolfram.com/xid/0tzqi180-32e7wj

https://wolfram.com/xid/0tzqi180-rtnqpj


https://wolfram.com/xid/0tzqi180-xdfmrc

https://wolfram.com/xid/0tzqi180-9l6r7t


https://wolfram.com/xid/0tzqi180-v10pfi

https://wolfram.com/xid/0tzqi180-16z0x


https://wolfram.com/xid/0tzqi180-4rpya3

https://wolfram.com/xid/0tzqi180-pp24va


https://wolfram.com/xid/0tzqi180-xk94z7

https://wolfram.com/xid/0tzqi180-jyy4f6


https://wolfram.com/xid/0tzqi180-n9udql

https://wolfram.com/xid/0tzqi180-6qoj1


https://wolfram.com/xid/0tzqi180-fk54fc

https://wolfram.com/xid/0tzqi180-10oh4r



https://wolfram.com/xid/0tzqi180-nfvdj9

https://wolfram.com/xid/0tzqi180-o2sj45


https://wolfram.com/xid/0tzqi180-7f4rj1

https://wolfram.com/xid/0tzqi180-wz920r


https://wolfram.com/xid/0tzqi180-bp50b

https://wolfram.com/xid/0tzqi180-9biq25


https://wolfram.com/xid/0tzqi180-m4f4ut

https://wolfram.com/xid/0tzqi180-ch1vzf

Use a combination of symbols and symbol names:

https://wolfram.com/xid/0tzqi180-rxsim6

https://wolfram.com/xid/0tzqi180-prz7px

https://wolfram.com/xid/0tzqi180-rfj3a5

Using Patterns (5)
Specify symbols to clear as string patterns:

https://wolfram.com/xid/0tzqi180-c2ufd6

https://wolfram.com/xid/0tzqi180-d7ttq9

https://wolfram.com/xid/0tzqi180-rysaf

Clear all symbols in the current context:

https://wolfram.com/xid/0tzqi180-6slgzo

https://wolfram.com/xid/0tzqi180-r70m2k

https://wolfram.com/xid/0tzqi180-lgaxot

Clear all symbols in a given context:

https://wolfram.com/xid/0tzqi180-wqeqjc

https://wolfram.com/xid/0tzqi180-gc3xk2

https://wolfram.com/xid/0tzqi180-6wx1zi

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

https://wolfram.com/xid/0tzqi180-79mopk

https://wolfram.com/xid/0tzqi180-jzfeke
The symbols x1 and x2 were cleared, but y remains unaffected:

https://wolfram.com/xid/0tzqi180-etkvxn

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

https://wolfram.com/xid/0tzqi180-uheesw

https://wolfram.com/xid/0tzqi180-ry5ruf

https://wolfram.com/xid/0tzqi180-vhu5yu

Applications (2)Sample problems that can be solved with this function
Clear any old definitions before making new ones:

https://wolfram.com/xid/0tzqi180-lanl90

https://wolfram.com/xid/0tzqi180-o08r3d

https://wolfram.com/xid/0tzqi180-p7j2an

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

https://wolfram.com/xid/0tzqi180-g66m9s

https://wolfram.com/xid/0tzqi180-gc6puz

https://wolfram.com/xid/0tzqi180-jkeqi5

https://wolfram.com/xid/0tzqi180-di9eh8

https://wolfram.com/xid/0tzqi180-byveoq
Properties & Relations (6)Properties of the function, and connections to other functions
ClearAll[pattern] clears the same symbols as ClearAll/@Names[pattern]:

https://wolfram.com/xid/0tzqi180-g68m9z


https://wolfram.com/xid/0tzqi180-olxyis

Clear does not remove attributes, defaults or options:

https://wolfram.com/xid/0tzqi180-d9ifq8

https://wolfram.com/xid/0tzqi180-szk4x2

https://wolfram.com/xid/0tzqi180-2pzvt9

Use ClearAll to clear everything:

https://wolfram.com/xid/0tzqi180-fc1pz8

https://wolfram.com/xid/0tzqi180-foikwx

Clear does not remove messages:

https://wolfram.com/xid/0tzqi180-3r2fk5

https://wolfram.com/xid/0tzqi180-1rtdik

https://wolfram.com/xid/0tzqi180-fcys54

Use ClearAll to clear messages:

https://wolfram.com/xid/0tzqi180-0lejh3

https://wolfram.com/xid/0tzqi180-3t4ohc

ClearAll removes all properties and definitions but leaves the symbol intact:

https://wolfram.com/xid/0tzqi180-fo51hr

https://wolfram.com/xid/0tzqi180-gw9s5s

https://wolfram.com/xid/0tzqi180-9s7bx

Remove removes the symbol completely:

https://wolfram.com/xid/0tzqi180-2ttji2

https://wolfram.com/xid/0tzqi180-qsshor

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

https://wolfram.com/xid/0tzqi180-mpj5jz

https://wolfram.com/xid/0tzqi180-wqsuy

https://wolfram.com/xid/0tzqi180-z4e5a

Clear all definitions and properties:

https://wolfram.com/xid/0tzqi180-dvfuo1

https://wolfram.com/xid/0tzqi180-fjiqex

ClearAll has the attribute HoldAll:

https://wolfram.com/xid/0tzqi180-fj68d5


https://wolfram.com/xid/0tzqi180-fx3wr4

https://wolfram.com/xid/0tzqi180-q7exta

https://wolfram.com/xid/0tzqi180-svaskv


https://wolfram.com/xid/0tzqi180-4nh32l

https://wolfram.com/xid/0tzqi180-mi3omu

https://wolfram.com/xid/0tzqi180-i9ltzh

Possible Issues (3)Common pitfalls and unexpected behavior
Protected symbols cannot be cleared:

https://wolfram.com/xid/0tzqi180-f41vz7

https://wolfram.com/xid/0tzqi180-npqgli

Use Unprotect to clear definitions of protected symbols:

https://wolfram.com/xid/0tzqi180-csvxte
Clear can clear the values and definitions for locked symbols:

https://wolfram.com/xid/0tzqi180-hu4t7s

https://wolfram.com/xid/0tzqi180-yxas0w


https://wolfram.com/xid/0tzqi180-ceqn5b

https://wolfram.com/xid/0tzqi180-3qij9n

ClearAll does not affect locked symbols:

https://wolfram.com/xid/0tzqi180-ytpq5c

https://wolfram.com/xid/0tzqi180-sc85rq


https://wolfram.com/xid/0tzqi180-lyw8mz

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

https://wolfram.com/xid/0tzqi180-yjoaby




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

https://wolfram.com/xid/0tzqi180-fhjmtu

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

https://wolfram.com/xid/0tzqi180-8w4y3l
Wolfram Research (1988), ClearAll, Wolfram Language function, https://reference.wolfram.com/language/ref/ClearAll.html (updated 2022).
Text
Wolfram Research (1988), ClearAll, Wolfram Language function, https://reference.wolfram.com/language/ref/ClearAll.html (updated 2022).
Wolfram Research (1988), ClearAll, Wolfram Language function, https://reference.wolfram.com/language/ref/ClearAll.html (updated 2022).
CMS
Wolfram Language. 1988. "ClearAll." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/ClearAll.html.
Wolfram Language. 1988. "ClearAll." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/ClearAll.html.
APA
Wolfram Language. (1988). ClearAll. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClearAll.html
Wolfram Language. (1988). ClearAll. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ClearAll.html
BibTeX
@misc{reference.wolfram_2025_clearall, author="Wolfram Research", title="{ClearAll}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/ClearAll.html}", note=[Accessed: 11-July-2025
]}
BibLaTeX
@online{reference.wolfram_2025_clearall, organization={Wolfram Research}, title={ClearAll}, year={2022}, url={https://reference.wolfram.com/language/ref/ClearAll.html}, note=[Accessed: 11-July-2025
]}