var a = "1.1.1.1,2.2.2.2,3.3.3.3"; var b = a.split(',').map(function (str) { return '"' + str+ '"'; }).join(','); console.log(b);