ToExpression

ToExpression[input]
gives the expression obtained by interpreting strings or boxes as Mathematica 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.

DetailsDetails

ExamplesExamplesopen allclose all

Basic Examples (5)Basic Examples (5)

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]=
New in 1 | Last modified in 5.1
New to Mathematica? Find your learning path »
Have a question? Ask support »