StringRiffle[{s1,s2,s3,…}]
creates a string by concatenating all the si, with spaces inserted between them.
StringRiffle[{{s11,s12,…},{s21,s22,…},…}]
creates a string by concatenating the sij, and inserting spaces at the lowest level and newlines at the higher level.
StringRiffle[list,sep]
inserts the separator sep between all elements in list.
StringRiffle[list,{"left","sep","right"}]
use left and right as delimiters after concatenation.
StringRiffle[list,sep1,sep2,…]
inserts separator sepi between elements of list at level i.
StringRiffle
StringRiffle[{s1,s2,s3,…}]
creates a string by concatenating all the si, with spaces inserted between them.
StringRiffle[{{s11,s12,…},{s21,s22,…},…}]
creates a string by concatenating the sij, and inserting spaces at the lowest level and newlines at the higher level.
StringRiffle[list,sep]
inserts the separator sep between all elements in list.
StringRiffle[list,{"left","sep","right"}]
use left and right as delimiters after concatenation.
StringRiffle[list,sep1,sep2,…]
inserts separator sepi between elements of list at level i.
Details
- Any element of list that is not a string is converted to a string using TextString.
- In StringRiffle[list], spaces are used as separators at the lowest level. At the next level up, newlines are used. At each higher level, successively more newlines are used.
Examples
open all close allBasic Examples (5)
Insert spaces between successive elements:
StringRiffle[{"a", "b", "c", "d", "e"}]Insert a specific string between elements:
StringRiffle[{"a", "b", "c", "d", "e"}, ", "]Specify delimiters to use at the beginning and end of the result:
StringRiffle[{"a", "b", "c", "d", "e"}, {"(", " ", ")"}]Using newlines and spaces as separators:
StringRiffle[{{"a", "b", "c"}, {"d", "e", "f"}}]Specify separators at each level:
StringRiffle[{{"a", "b", "c"}, {"d", "e", "f"}}, "
", " "]Scope (5)
Insert spaces between elements of a list of strings:
StringRiffle[{"apples", "oranges", "lemons"}]Do the same using an explicit space delimiter:
StringRiffle[{"apples", "oranges", "lemons"}, " "]Insert spaces at the inner level and newlines at the outer level:
StringRiffle[{{"apples", "oranges"}, {"lemons", "limes"}}]StringRiffle[{"a", "b", "c"}, ", "]StringRiffle[{"John", "Steve", "Bill"}, " and "]Specify initial and final delimiters:
StringRiffle[{"a", "b", "c"}, {"(", ", ", ")"}]StringRiffle[{"John", "Steve", "Bill"}, {"The students ", " and ", " study mathematics"}]Insert colons at the bottom level, commas at the top level, and braces as overall surrounding delimiters:
StringRiffle[{{"red", "1"}, {"green", "2"}, {"blue", "3"}}, {"{", ", ", "}"}, ": "]Do the same using numbers that are automatically converted to strings:
StringRiffle[{{"red", 1}, {"green", 2}, {"blue", 3}}, {"{", ", ", "}"}, ": "]Generalizations & Extensions (1)
Applications (3)
Convert the contents of a matrix to a string:
StringRiffle[RandomInteger[9, {8, 8}]]Convert a table to a string in a TSV (tab-separated values) format:
StringRiffle[{{1, "a", Yesterday}, {2, "b", Today}, {3, "c", Tomorrow}}, "
", " "]Rewrite a list of key-value pairs into a JSON-like string:
StringRiffle[{{"a", 27}, {"b", 28}, {"c", 29}}, {"{", ", ", "}"}, ": "]Properties & Relations (1)
Values that are not strings are converted to strings using TextString:
StringRiffle[Range[10], ", "]Related Guides
History
Text
Wolfram Research (2015), StringRiffle, Wolfram Language function, https://reference.wolfram.com/language/ref/StringRiffle.html.
CMS
Wolfram Language. 2015. "StringRiffle." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/StringRiffle.html.
APA
Wolfram Language. (2015). StringRiffle. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/StringRiffle.html
BibTeX
@misc{reference.wolfram_2026_stringriffle, author="Wolfram Research", title="{StringRiffle}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/StringRiffle.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_stringriffle, organization={Wolfram Research}, title={StringRiffle}, year={2015}, url={https://reference.wolfram.com/language/ref/StringRiffle.html}, note=[Accessed: 12-June-2026]}