I'm trying to use Manipulate to specify a list of numbers on the user side, say {50,60,70,80,90,95,99}, but I don't want the curly braces to need to be in the text entry box. i.e.

(*my code here*),


Has the functionality I want, but I would like to get rid of the curly braces that are displayed in the text entry field.

  • $\begingroup$ Whoops, had to make a small edit to the code. $\endgroup$
    – Daniel
    Commented Mar 1, 2021 at 23:11
  • $\begingroup$ Manipulate[(*my code here*)variable, {variable, {50, 60, 70, 80, 90, 95, 99}}] ? $\endgroup$
    – cvgmt
    Commented Mar 1, 2021 at 23:26

3 Answers 3


I prefer using the tracking function in Dynamic, which makes managing TrackedSymbols easier in Manipulate.

 {{variable, {50, 60, 70, 80, 90, 95, 99}}, InputField[
     StringTrim[ToString@variable, "{" | "}"],
     With[{v = ToExpression["{" <> # <> "}"]},
        variable = v,
        (* raise exception *)
       ] &
    String] &}

I believe to maximize the experience for the end users, the best way would be to employ the API related functionalities. You may see the following entries:

You may try using the following construct:

  Interpreter["Number" | DelimitedSequence["Number"] | 
              DelimitedSequence["Number", {"{", ",", "}"}]][variable];
  (*your code here*)
 ], {{variable, 
  ToString@{50, 60, 70, 80, 90, 95, 99}}, 
 InputField[#, String]&

This shall provide a robust interface, for many sort of input.

Screenshots of results: Input a valid Wolfram list Input with out brackets Input as space separated sequence


Welcome to MMA SE! So, one way to do this is to actually treat the manipulated variable as a string, and then parse it into your "real" variable in the code.

So, to do that, we're going to make two quick functions: one to convert lists to strings-without-brackets, and one to convert back.

ListToString[l_List] := StringTake[ToString[l], {2, -2}]

StringToList[s_String] := ToExpression["{" <> StringTrim[s,","] <> "}"]

In the first, it takes characters 2 to the penultimate one (-2), thus excluding the braces at either end, and in the second, it string-joins (<>) curly braces at either end and then parses it as a Mathematica expression via ToExpression.

You might be wondering why StringTrim[s, ","] is in there; that's just to trim off any trailing commas if your user forgets! (E.g. if their input is "1,2,3," and they forgot to delete the last comma; this will take care of that behind the scenes for them.)

So, inside the Manipulate, at the start of the code labeled (*my code here*) in your question, you'll want to insert the following:

realvariable = StringToList[strvariable]; (*my code here*)

This will parse your input whenever your user presses Enter.

Now change your Manipulate variable specification to

{{strvariable, ListToString[{50,60,70,80,90,95,99}]}, InputField[#, String] &}

Using InputField[#, String] & will make `InputField format the string nicely, without quotes.

Also, as a note: it would be wise to put this realvariable in a Module, so that the variable realvariable is trapped inside the manipulate, e.g.

    realvariable = StringToList[strvariable];
    (*my code here*)
  {{strvariable, ListToString[{50,60,70,80,90,95,99}]},
    InputField[#, String] &}

Let me know if it's unclear how any of this works!


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.