Remove[s1,s2,…]
removes the symbols si completely, so that their names are no longer recognized by the Wolfram Language.
Remove[patt1,patt2,…]
removes all symbols whose names textually match any of the arbitrary string patterns patti.
Remove[{spec1,spec2,…}]
removes any symbols that are equal to or whose names match any of the speci.
Remove
Remove[s1,s2,…]
removes the symbols si completely, so that their names are no longer recognized by the Wolfram Language.
Remove[patt1,patt2,…]
removes all symbols whose names textually match any of the arbitrary string patterns patti.
Remove[{spec1,spec2,…}]
removes any symbols that are equal to or whose names match any of the speci.
Details
- You can use Remove to get rid of symbols that you do not need, and which may shadow symbols in contexts later on your context path. »
- The pattern patt can be given as a string with metacharacters, as StringExpression[…] or as RegularExpression["regex"]. »
- Remove allows abbreviated string patterns containing the following metacharacters:
-
* match zero or more characters @ match one or more characters, but not uppercase letters - Remove["context`*"] removes all symbols in a particular context. »
- Remove["`*"] removes all symbols in the current context. »
- Once you have removed a symbol, you will never be able to refer to it again, unless you recreate it.
- If you have an expression that contains a symbol that you remove, the removed symbol will be printed as Removed["name"], where its name is given in a string. »
- Remove works with LocalSymbol, CloudSymbol, PersistentSymbol and InitializationValue objects. »
- Remove does not affect symbols with the attributes Locked or Protected. »
- Remove has attribute HoldAll. »
Examples
open all close allBasic Examples (1)
Scope (11)
Symbol Inputs (2)
a = 5;
f[x_] := x ^ 3f[a]Remove[a, f]They are no longer recognized as valid names:
{NameQ["f"], NameQ["a"]}Use a combination of symbols and symbol names:
x1 = 1;x2 = 3;x3 = 5;Remove[{x1, "x2"}]Only x3 remains known to the system:
Names["x*"]Using Patterns (5)
Specify symbols to remove as string patterns:
x1 = 1;x2 = 3;y = 5;Remove["x*"]? x*Remove all symbols in the current context:
x1 = 1;x2 = 3;y = 5;Remove["`*"]There are no longer any symbols in the current context:
Names[$Context <> "*"]Remove all symbols in a given context:
abc`x1 = 1;abc`x2 = 3;abc`y = 5;Remove["abc`*"]{NameQ["abc`x1"], NameQ["abc`x2"], NameQ["abc`y"]}Remove all 2-character symbols in the current context using StringExpression:
x1 = 1;x2 = 3;y = 5;Remove["`" ~~ _ ~~ _]The symbols x1 and x2 were removed, but y remains unaffected:
{NameQ["x1"], NameQ["x2"], y}Remove all 3-character symbols in the current context using RegularExpression:
x = 1;yy = 3;zzz = 5;Remove[RegularExpression["`..."]]{x, yy, zzz}Symbol-like Objects (4)
LocalSymbol["mysym"] = 17Remove[LocalSymbol["mysym"]]LocalSymbol["mysym"]CloudSymbol["x"] = 42;Remove[CloudSymbol["x"]]CloudSymbol["x"]PersistentSymbol["x"] = 42;Remove[PersistentSymbol["x"]]PersistentSymbol["x"]Remove initialization values for a symbol:
InitializationValue["x"] = 42;Remove[InitializationValue["x"]]Initialize["x"];xApplications (1)
If a symbol from a package is used before the package is loaded, an extra symbol is created:
ErrorListPlot[Table[{i, RandomReal[0.5]}, {i, 10}]]Needs["ErrorBarPlots`"]The extra symbol in the current context should be removed:
Remove[`ErrorListPlot]Only the correct symbol from the package remains:
ErrorListPlot[Table[{i, RandomReal[0.5]}, {i, 10}]]Properties & Relations (5)
Remove[pattern] removes the same symbols as Remove/@Names[pattern]:
x = 1;y = 2; xy = 3;
Remove["x*"];
{NameQ["x"], NameQ["y"], NameQ["xy"]}x = 1;y = 2; xy = 3;
Remove /@ Names["x*"];
{NameQ["x"], NameQ["y"], NameQ["xy"]}If a symbol is removed, all of its properties and definitions are removed as well:
SetAttributes[f, Listable];
Default[f] = 0;
Options[f] = {opt1 -> def1, opt2 -> def2};
f::usage = "message";
f[x_.] := x ^ 2Remove[f]? fUsing the same symbol again creates a new one without any of its old properties:
Definition[f]ClearAll also removes all properties and definitions but leaves the symbol intact:
SetAttributes[f, Listable];
f[x_] := x ^ 2ClearAll[f]? fRemove removes the symbol completely:
Remove[f]? fIf an expression still refers to a removed symbol, those places are denoted with Removed:
expr = {x, y, z};Remove[y]exprRemove has the attribute HoldAll:
Definition[Remove]symbol = {"x", "y", "z"};x = 1;y = 3;z = 5;Remove[symbol]{NameQ["symbol"], NameQ["x"], NameQ["y"], NameQ["z"]}symbol = {"x", "y", "z"};Remove[Evaluate[symbol]]{NameQ["symbol"], NameQ["x"], NameQ["y"], NameQ["z"]}Possible Issues (3)
Protected symbols cannot be removed:
x = 5;
Protect[x];Remove[x]Use Unprotect to remove protected symbols:
Unprotect[x];
Remove[x]Remove does not affected locked symbols:
SetAttributes[f, Locked]Remove[f]Definition[f]When using a pattern without a context mark, all matching symbols on $ContextPath are removed:
x = 1;y = 2;xy = 3;
Remove[_ ~~ _]The symbol xy was removed, along with attempts to remove several system symbols:
NameQ["xy"]Use a pattern with an explicit context mark to avoid potentially matching symbols from system or other contexts:
Remove["`" ~~ _]Tech Notes
Related Guides
Related Workflows
- Clear Definitions for Symbols and Functions ▪
- Handle Shadowing of Symbol Names
History
Introduced in 1988 (1.0) | Updated in 2016 (11.0) ▪ 2022 (13.2)
Text
Wolfram Research (1988), Remove, Wolfram Language function, https://reference.wolfram.com/language/ref/Remove.html (updated 2022).
CMS
Wolfram Language. 1988. "Remove." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/Remove.html.
APA
Wolfram Language. (1988). Remove. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Remove.html
BibTeX
@misc{reference.wolfram_2026_remove, author="Wolfram Research", title="{Remove}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/Remove.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_remove, organization={Wolfram Research}, title={Remove}, year={2022}, url={https://reference.wolfram.com/language/ref/Remove.html}, note=[Accessed: 13-June-2026]}