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

How Input and Output WorkThe Interpretation of Textual Forms

2.8.3 The Representation of Textual Forms

Like everything else in Mathematica the textual forms of expressions can themselves be represented as expressions. Textual forms that consist of one-dimensional sequences of characters can be represented directly as ordinary Mathematica strings. Textual forms that involve subscripts, superscripts and other two-dimensional constructs, however, can be represented by nested collections of two-dimensional boxes.

Typical representations of textual forms.

This generates the string corresponding to the textual representation of the expression in InputForm.

In[1]:= ToString[x^2 + y^3, InputForm]

Out[1]=

FullForm shows the string explicitly.

In[2]:= FullForm[%]

Out[2]//FullForm=

Here are the individual characters in the string.

In[3]:= Characters[%]

Out[3]=

Here is the box structure corresponding to the expression in StandardForm.

In[4]:= ToBoxes[x^2 + y^3, StandardForm]

Out[4]=

Here is the InputForm of the box structure. In this form the structure is effectively represented by an ordinary string.

In[5]:= ToBoxes[x^2 + y^3, StandardForm] // InputForm

Out[5]//InputForm= \(x\^2 + y\^3\)

If you use the notebook front end for Mathematica, then you can see the expression that corresponds to the textual form of each cell by using the Show Expression menu item.

Here is a cell containing an expression in StandardForm.

Here is the underlying representation of that expression in terms of boxes, displayed using the Show Expression menu item.

Creating strings and boxes from expressions.

How Input and Output WorkThe Interpretation of Textual Forms