Search for all pages containing ToExpression
ToExpression[input]
gives the expression obtained by interpreting strings or boxes as Wolfram Language input.
ToExpression[input,form]
uses interpretation rules corresponding to the specified form.
ToExpression[input,form,h]
wraps the head h around the expression produced before evaluating it.


ToExpression
ToExpression[input]
gives the expression obtained by interpreting strings or boxes as Wolfram Language input.
ToExpression[input,form]
uses interpretation rules corresponding to the specified form.
ToExpression[input,form,h]
wraps the head h around the expression produced before evaluating it.
Details

- form can be InputForm, StandardForm, TeXForm, TraditionalForm, or MathMLForm.
- ToExpression["string"] uses InputForm interpretation rules.
- ToExpression[boxes] uses StandardForm interpretation rules.
- ToExpression prints a message and returns $Failed if it finds a syntax error. ToExpression does not call $SyntaxHandler. »
- The input given in ToExpression can correspond to multiple Wolfram Language expressions. ToExpression processes each one in turn, just like Get. »
- ToExpression[input,form,Hold] can be used to convert input to an expression, but with the expression wrapped in Hold to prevent evaluation. »
- ToExpression uses any relevant definitions given for MakeExpression.
Examples
open all close allBasic Examples (5)
Convert a string to an expression, and evaluate the expression:
Interpret a TraditionalForm string:
Convert boxes to Wolfram Language input:
Scope (2)
Convert a string to an expression using TraditionalForm rules:
Convert the same string using StandardForm and InputForm rules:
Convert and evaluate a string representing multiple lines of code:
Generalizations & Extensions (1)
Apply the head Hold to prevent evaluation:
Properties & Relations (2)
ToExpression evaluates the expression, while MakeExpression does not:
Display an InterpretationBox:
The expression is the second argument of the InterpretationBox:
See Also
Interpreter Symbol MakeExpression ToString ToBoxes SyntaxQ SyntaxLength Read Get ImportString
Function Repository: StringTemplateInput ConvertStringsToSymbols
Tech Notes
History
Introduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2003 (5.0) ▪ 2004 (5.1)
Text
Wolfram Research (1988), ToExpression, Wolfram Language function, https://reference.wolfram.com/language/ref/ToExpression.html (updated 2004).
CMS
Wolfram Language. 1988. "ToExpression." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2004. https://reference.wolfram.com/language/ref/ToExpression.html.
APA
Wolfram Language. (1988). ToExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ToExpression.html
BibTeX
@misc{reference.wolfram_2025_toexpression, author="Wolfram Research", title="{ToExpression}", year="2004", howpublished="\url{https://reference.wolfram.com/language/ref/ToExpression.html}", note=[Accessed: 06-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_toexpression, organization={Wolfram Research}, title={ToExpression}, year={2004}, url={https://reference.wolfram.com/language/ref/ToExpression.html}, note=[Accessed: 06-August-2025]}