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

Examples

open allclose all

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 Wolfram Language input:

In[1]:=
Click for copyable input
Out[1]=

Convert MathML strings to expressions:

In[1]:=
Click for copyable input
Out[1]=

Convert TAdjustmentBox[E, BoxBaselineShift -> 0.5, BoxMargins -> {{-0.3, 0}, {0, 0}}]X strings to expressions:

In[1]:=
Click for copyable input
Out[1]=

Scope  (2)

Generalizations & Extensions  (1)

Properties & Relations  (2)

Possible Issues  (1)

See Also

Interpreter  Symbol  MakeExpression  ToString  ToBoxes  SyntaxQ  SyntaxLength  Read  Get  ImportString

Tutorials

Introduced in 1988
(1.0)
| Updated in 2004
(5.1)