is the head of a character string "text".
String 
is the head of a character string "text".
Details
- Strings can contain any sequence of ordinary or special characters. »
- _String can be used as a pattern that represents a string.
- In FullForm, special characters in strings are given as
or
. » - If an explicit newline in the string is preceded by a single backslash \, the backslash and newline are ignored.
Examples
open all close allBasic Examples (1)
"This is a string."InputForm shows quotes:
InputForm[%]Scope (6)
Enter explicit newlines using \n:
"one
two
three""" is the empty string, which normally does not print:
{"", x, "", ""}InputForm explicitly shows the empty strings:
InputForm[%]Strings can contain any sequence of ordinary and special characters:
"◆ String αβγ ⟷ 𝒜ℬ𝒞 ↵"In FullForm, full character names are used:
FullForm[%]Strings preserve internal formatting:
"red blue green *italic*"All strings have head String:
Head["a string"]_String matches any string, but not a symbol:
Cases[{1, 2, "ab", "cd", x, y}, _String]Generalizations & Extensions (2)
Applications (5)
Print text (the quotes do not appear by default):
Print["The answer is ", 2 ^ 45]Style["This is a string.", FontSize -> 25, FontFamily -> "Helvetica"]Define a function that applies only to strings:
f[s_String] := StringJoin[RotateLeft[Characters[s]]]{f["X"], f["ABCDEF"], f[x], f[{a, b, c}]}ListPlot[{{1, 2, 3}, {3, 1, 4}}, PlotMarkers -> {"A", "B"}]Graphics[{Text["abcde", {0, -2}], Disk[{0, 0}], Text["ABCDE", {0, 2}]}]Properties & Relations (5)
Break a string into characters:
Characters["This is a string."]StringJoin[%]Find character codes for characters in a string:
ToCharacterCode["This is a string."]FromCharacterCode[%]Turn a string into an expression:
ToExpression["1+x^4"]ToString creates strings, by default with OutputForm:
ToString[1 + x ^ 4]FullForm[%]Create a string containing InputForm:
ToString[1 + x ^ 4, InputForm]FullForm[%]Possible Issues (5)
Use \" to enter a " inside a string:
"a string with \"quotes\""Strings are treated as "atoms" with no parts:
Length["a string"]Use StringLength to find the character length of a string:
StringLength["a string"]Strings do not automatically insert spacing around operator characters:
"x->a+b+c+d"x -> a + b + c + dAn InputForm string contains explicit space characters:
ToString[%, InputForm]The actual sequences of characters in a formatted string can be fairly complicated:
FullForm["red *italic*"]FullForm["ab [image] cd"]A string with special characters usually does not include the long form of the character:
"α"Force long form names to be used:
ToString[FullForm["α"]]ToString["α", InputForm, CharacterEncoding -> None]History
Introduced in 1988 (1.0) | Updated in 1996 (3.0)
Text
Wolfram Research (1988), String, Wolfram Language function, https://reference.wolfram.com/language/ref/String.html (updated 1996).
CMS
Wolfram Language. 1988. "String." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 1996. https://reference.wolfram.com/language/ref/String.html.
APA
Wolfram Language. (1988). String. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/String.html
BibTeX
@misc{reference.wolfram_2026_string, author="Wolfram Research", title="{String}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/String.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_string, organization={Wolfram Research}, title={String}, year={1996}, url={https://reference.wolfram.com/language/ref/String.html}, note=[Accessed: 12-June-2026]}