WOLFRAM

Enable JavaScript to interact with content and submit forms on Wolfram websites. Learn how
Wolfram Language & System Documentation Center

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
Details and Options Details and Options
Examples  
Basic Examples  
Scope  
Options  
CharacterEncoding  
FormatType  
NumberMarks  
PageWidth  
Applications  
Properties & Relations  
Possible Issues  
See Also
Tech Notes
Related Guides
Related Workflows
Related Links
History
Cite this Page

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 all close all

Basic Examples  (2)

Give a string corresponding to the OutputForm of x2:

Give a string corresponding to the InputForm :

Scope  (2)

Strings for OutputForm , InputForm , StandardForm , and TraditionalForm of an expression:

Non-default character encoding:

Options  (4)

CharacterEncoding  (1)

Generate a string using the default encoding:

Use ASCII encoding instead:

FormatType  (1)

Use FormatType to change the formatting:

NumberMarks  (1)

Use the default setting of InputForm formatting:

Explicitly set whether number marks should be included:

PageWidth  (1)

By default, the page width is infinite:

Wrap to a new line after 9 characters in the string:

Applications  (2)

Construct an indexed set of variables:

Export data to files with programmatically created names:

Properties & Relations  (3)

Use ToExpression to convert strings or boxes to expressions:

Use ToBoxes to convert expressions to boxes:

Use ToString with ToExpression to convert TeX to Wolfram Language syntax:

ToString uses definitions from Format and MakeBoxes :

Possible Issues  (1)

ToString by default uses OutputForm formatting:

Specify other formats to preserve styling information:

See Also

ToBoxes   ToExpression   HoldForm   WriteString   TextString   SymbolName   StringTemplate

Function Repository: ToFullString

Related Workflows

History

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

Wolfram Research (1988), ToString, Wolfram Language function, https://reference.wolfram.com/language/ref/ToString.html (updated 1996).

Text

Wolfram Research (1988), ToString, Wolfram Language function, https://reference.wolfram.com/language/ref/ToString.html (updated 1996).

CMS

Wolfram Language. 1988. "ToString." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/ToString.html.

APA

Wolfram Language. (1988). ToString. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ToString.html

BibTeX

@misc{reference.wolfram_2025_tostring, author="Wolfram Research", title="{ToString}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/ToString.html}", note=[Accessed: 05-December-2025]}

BibLaTeX

@online{reference.wolfram_2025_tostring, organization={Wolfram Research}, title={ToString}, year={1996}, url={https://reference.wolfram.com/language/ref/ToString.html}, note=[Accessed: 05-December-2025]}

Top [フレーム]

AltStyle によって変換されたページ (->オリジナル) /