var str = "www.baidu.com?id=1&name=zhangsan"; var data = str.split("?"); console.log(data); var zz = "{""+data[1].replace(/=/g,"":"").replace("&","","")+""}"; console.log(zz); var json = JSON.parse(zz); console.log(json);