var labels = ["DESKTOP", "MOBILE", "TABLET"]; var chartData = ["100", "10", "15"]; var myData = []; labels.forEach(function(e, i) { myData.push({ label: e, data: chartData[i] }) }) document.write(JSON.stringify(myData));