This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

ToExpression

ToExpression[input]
gives the expression obtained by interpreting strings or boxes as Mathematica input.
ToExpression
uses interpretation rules corresponding to the specified form.
ToExpression
wraps the head h around the expression produced before evaluating it.
  • ToExpression[input, form, Hold] can be used to convert input to an expression, but with the expression wrapped in Hold to prevent evaluation. »
Convert a string to an expression, and evaluate the expression:
Interpret a TraditionalForm string:
Convert boxes to Mathematica input:
Convert MathML strings to expressions:
Convert strings to expressions:
Convert a string to an expression, and evaluate the expression:
In[1]:=
Click for copyable input
Out[1]=
 
Interpret a TraditionalForm string:
In[1]:=
Click for copyable input
Out[1]=
 
Convert boxes to Mathematica input:
In[1]:=
Click for copyable input
Out[1]=
 
Convert MathML strings to expressions:
In[1]:=
Click for copyable input
Out[1]=
 
Convert strings to expressions:
In[1]:=
Click for copyable input
Out[1]=
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:
Apply the head Hold to prevent evaluation:
ToExpression evaluates the expression, while MakeExpression does not:
Display an InterpretationBox:
The expression is the second argument of the InterpretationBox:
Input containing invalid or incomplete syntax cannot be converted to expressions:
New in 1 | Last modified in 5.1