ToString

ToString[expr]

gives a string corresponding to the printed form of expr in OutputForm.

ToString[expr,form]

gives the string corresponding to output in the specified form.

Details and Options

Examples

open allclose all

Basic Examples  (2)

Give a string corresponding to the OutputForm of x2:

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

Give a string corresponding to the InputForm:

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

Scope  (2)

Options  (4)

Applications  (2)

Properties & Relations  (4)

Possible Issues  (1)

See Also

ToBoxes  ToExpression  HoldForm  WriteString  TextString  SymbolName  StringTemplate

Tutorials

Introduced in 1988
(1.0)
| Updated in 1996
(3.0)