This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Built-in Functions / Input and Output / Formatting Functions  /
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.
  • ToString supports the same set of options as OpenAppend, with default settings FormatType -> OutputForm, PageWidth -> Infinity, TotalWidth -> Infinity.
  • ToString uses any relevant definitions given for Format and MakeBoxes.
  • See the Mathematica book: Section 2.8.3.
  • See also: ToBoxes, ToExpression, HoldForm, WriteString, SymbolName.

    Further Examples

    This generates a string from the (evaluated) expression.

    In[1]:=

    Out[1]=

    In[2]:=

    Out[2]//FullForm=

    In[3]:=