ExportString[expr,"format"]
generates a string corresponding to expr exported in the specified format.
ExportString[rules,{"format","Rules"}]
gives explicit rules for different elements of the data to be exported.
ExportString[exprs,elems]
generates a string by treating exprs as elements specified by elems.
ExportString
Listing of Formats »ExportString[expr,"format"]
generates a string corresponding to expr exported in the specified format.
ExportString[rules,{"format","Rules"}]
gives explicit rules for different elements of the data to be exported.
ExportString[exprs,elems]
generates a string by treating exprs as elements specified by elems.
Details
- ExportString generates a string corresponding to data exported in the specified format.
- ExportString handles a large number of formats, each typically with many different possible elements. The possible formats are given in the list $ExportFormats, and in the "Listing of All Formats".
- ExportString works just like Export, with the same element specifications and options.
- Many graphics, sound, and binary formats yield strings containing non‐printable characters.
Examples
open all close allBasic Examples (2)
Scope (4)
Export an array to a "CSV" string:
ExportString[{{1, "one"}, {2, "two"}}, "CSV"]Export the same array to a "JSON" string:
ExportString[{{1, "one"}, {2, "two"}}, "JSON"]Export a graph as a "Graph6" string:
ExportString[HypercubeGraph[3], "Graph6"]Export with an option to suppress the header:
ExportString[HypercubeGraph[3], "Graph6", "Header" -> False]Export multiple graphs as "Graph6" strings:
ExportString[Table[HypercubeGraph[n], {n, 0, 4}], "Graph6", "Header" -> False]Many formats give strings containing non-printable characters:
ExportString[[image], "GIF"]//InputFormFullForm[%]Export a "ZIP" file with multiple subelements using the "Rules" syntax:
zipData = ExportString[ <|"a.gif" -> \!\(\*GraphicsBox[«3»]\), "b.txt" -> "earth seen from space"|>, {"ZIP", "Rules"} ];Verify the resulting files in the ZIP data:
ImportString[zipData]This is equivalent to the following syntax using subelements:
zipData = ExportString[{\!\(\*GraphicsBox[«3»]\), "earth seen from space"}, {"ZIP", {"a.gif", "b.txt" }}];Verify the resulting files in the ZIP data:
ImportString[zipData]See Also
ImportString Export ExportByteArray Rasterize BaseEncode Compress FunctionCompileExportString
Function Repository: SaveAsString
History
Introduced in 1999 (4.0) | Updated in 2003 (5.0) ▪ 2004 (5.1) ▪ 2007 (6.0)
Text
Wolfram Research (1999), ExportString, Wolfram Language function, https://reference.wolfram.com/language/ref/ExportString.html (updated 2007).
CMS
Wolfram Language. 1999. "ExportString." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2007. https://reference.wolfram.com/language/ref/ExportString.html.
APA
Wolfram Language. (1999). ExportString. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExportString.html
BibTeX
@misc{reference.wolfram_2026_exportstring, author="Wolfram Research", title="{ExportString}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/ExportString.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_exportstring, organization={Wolfram Research}, title={ExportString}, year={2007}, url={https://reference.wolfram.com/language/ref/ExportString.html}, note=[Accessed: 13-June-2026]}