MSPToExpression[var]
interprets the variable var.
MSPToExpression[var, mt]
uses the format fmt to interpret var.
MSPToExpression[ var,fmt,head]
returns the result wrapped in head.


MSPToExpression
MSPToExpression[var]
interprets the variable var.
MSPToExpression[var, mt]
uses the format fmt to interpret var.
MSPToExpression[ var,fmt,head]
returns the result wrapped in head.
Details
- MSPToExpression is the MSP version of ToExpression. It provides the same functionality for turning strings into Mathematica input, but it also carries out a security check.
- You should always use MSPToExpression rather than ToExpression in your code because it provides additional security.
- The following exceptions can be thrown by MSPToExpression:
-
MSPException["ParseError"] if the value cannot be interpreted by the Wolfram Kernel MSPException["SecurityError"] if the value does not pass the security test MSPException["ValueError"] if the value is not a string; this indicates a programmatic error by the page author MSPException["NoValueError"] if the variable does not have a value; this indicates a programmatic error by the page author MSPException["VariableError"] if the variable is not a Wolfram Language symbol; this indicates a programmatic error by the page author
Examples
Basic Examples (1)
You can simulate how the functions work by loading the package and setting the security content:
Here the variable $$var is assigned to the value "5+7"; note that the value is a string:
When MSPToExpression evaluates, the parsed value of $$var is returned:
If a variable has no value, an MSPException is thrown:

Like ToExpression, MSPToExpression can take a format type for interpretation:
If the input value cannot be interpreted, an MSPException is thrown:
If the input value does not pass the security test, an MSPException is thrown:
Text
Wolfram Research (1996), MSPToExpression, Wolfram Language function, https://reference.wolfram.com/language/WolframWebEngine/ref/MSPToExpression.html.
CMS
Wolfram Language. 1996. "MSPToExpression." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/WolframWebEngine/ref/MSPToExpression.html.
APA
Wolfram Language. (1996). MSPToExpression. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/WolframWebEngine/ref/MSPToExpression.html
BibTeX
@misc{reference.wolfram_2025_msptoexpression, author="Wolfram Research", title="{MSPToExpression}", year="1996", howpublished="\url{https://reference.wolfram.com/language/WolframWebEngine/ref/MSPToExpression.html}", note=[Accessed: 25-August-2025]}
BibLaTeX
@online{reference.wolfram_2025_msptoexpression, organization={Wolfram Research}, title={MSPToExpression}, year={1996}, url={https://reference.wolfram.com/language/WolframWebEngine/ref/MSPToExpression.html}, note=[Accessed: 25-August-2025]}