How to execute a String code in the form of StandardForm?

I want to get execution results for strings of various forms. For this, I used ToExpression.

case1 = ToExpression["(1/2)^3"]
case2 = ToExpression["\!\(\*SuperscriptBox[FractionBox[\(1\), \(2\)], \(3\)]\)"]
case3 = ToExpression["(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \\(3\)]\)"]

enter image description here

As a result of execution, Case 3 did not get the result I wanted. How can I solve it?

Here's a GIF showing how 3rd string is created:


As we can see, once the pair of " is added, the size of () becomes a bit weird.

  • $\begingroup$ Looks like a bug of front-end. The pair of () isn't in a RowBox in 3rd case. If the string is obtained with e.g. ToString[(1/2)^3 // Unevaluated, StandardForm], ToExpression will handle it properly, though. $\endgroup$
    – xzczd
    Nov 15, 2023 at 4:38
  • $\begingroup$ I think it's better to report it to WRI: wolfram.com/support/contact/?topic=feedback $\endgroup$
    – xzczd
    Nov 15, 2023 at 4:54
  • $\begingroup$ Thank you for your answer. You see this as a bug? I've tested it in v11.3~13.3, but it shows the same symptoms. It's a problem that's been happening since the old version! $\endgroup$
    – Milk
    Nov 15, 2023 at 5:04
  • 1
    $\begingroup$ Yes, personally I think it's a bug. And it seems to be broken from the beginning (modern front-end is introduced in v3): i.stack.imgur.com/k5EBi.png $\endgroup$
    – xzczd
    Nov 15, 2023 at 5:21
  • 1
    $\begingroup$ @xzczd, oooh, I see it now, sorry. I retract my previous comment (: However, in my opinion, it should be noted that the bug is in this automatic conversion to the wrong box structure after wrapping in ". Perhaps this gif could be included in the question/bug report. $\endgroup$
    – Domen
    Nov 15, 2023 at 14:39

1 Answer 1


You can do:

"(\!\(\*FractionBox[\(1\), \(2\)]\)\!\(\*SuperscriptBox[\()\), \(3\)]\)" // 
  FrontEnd`ReparseBoxStructurePacket // FrontEndExecute // ToExpression
  • $\begingroup$ Oh I even upvoted some of those ReparseBoxStructurePacket answers but didn't notice the function is so powerful… Of course +1. $\endgroup$
    – xzczd
    Nov 15, 2023 at 11:01
  • $\begingroup$ @xzczd maybe it is, maybe it is not, worked this time :) $\endgroup$
    – Kuba
    Nov 15, 2023 at 13:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.