Compress[expr]
gives a compressed representation of expr as a string.
Compress
Compress[expr]
gives a compressed representation of expr as a string.
Details and Options
- Compress[expr] gives a compressed representation of any expression.
- The string generated by Compress contains only printable ASCII characters.
- Uncompress is the inverse of Compress.
Examples
open all close allBasic Examples (3)
A compressed representation of
with 100-digit precision:
Compress[N[Pi, 100]]Uncompress[%]a = Import["ExampleData/rose.gif"]Number of bytes used to store the image:
ByteCount[a]Number of bytes of a compressed representation of the image:
ByteCount[Compress[a]]Compress a general expression:
e = D[x ^ x, {x, 10}];In this case there is almost a factor of 50 compression:
{ByteCount[e], ByteCount[Compress[e]]}Properties & Relations (1)
See Also
Uncompress ByteCount CreateArchive ExportString Hash BinarySerialize InputForm Share
Function Repository: ToCompressedBoxes HuffmanCodeWords HuffmanEncode CompressCloudObject CompressWithDefinitions
Related Guides
History
Text
Wolfram Research (2007), Compress, Wolfram Language function, https://reference.wolfram.com/language/ref/Compress.html.
CMS
Wolfram Language. 2007. "Compress." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Compress.html.
APA
Wolfram Language. (2007). Compress. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Compress.html
BibTeX
@misc{reference.wolfram_2026_compress, author="Wolfram Research", title="{Compress}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/Compress.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_compress, organization={Wolfram Research}, title={Compress}, year={2007}, url={https://reference.wolfram.com/language/ref/Compress.html}, note=[Accessed: 12-June-2026]}