You can pass a regex into JavaScript's split() method. For example: "1,2 3".split(/,| /) ["1", "2", "3"] Or, if you want to allow multiple separators together to act as one only: "1, 2, , 3".split(/(?:,| )+/) ["1", "2", "3"]