This will convert it into an array (which is the JSON representation you specified):

var array = myString.split(',');

If you need the string version:

var string = JSON.stringify(array);
Answer from joeltine on Stack Overflow
๐ŸŒ
W3Resource
w3resource.com โ€บ javascript-exercises โ€บ fundamental โ€บ javascript-fundamental-exercise-4.php
JavaScript fundamental (ES6 Syntax): Convert a comma-separated values string to a 2D array of objects - w3resource
July 3, 2025 - const CSV_to_JSON = (data, delimiter = ',') => { // Extract titles from the first row of the CSV data. const titles = data.slice(0, data.indexOf('\n')).split(delimiter); // Split the CSV data by newline characters, map each row to a JSON object with titles as keys. return data .slice(data.indexOf('\n') + 1) .split('\n') .map(v => { const values = v.split(delimiter); // Create a JSON object using titles and corresponding values. return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); }); }; // Test cases console.log(CSV_to_JSON('col1,col2\na,b\nc,d')); // [{'col1':
Find elsewhere
๐ŸŒ
LinkedIn
linkedin.com โ€บ pulse โ€บ javascript-function-convert-comma-separated-values-string-milap-patel-1c
JavaScript Function To Convert A Comma-Separated Values String Into JSON !
August 18, 2023 - In this video, you will learn JavaScript Function To Convert A Comma-Separated Values String Into JSON ! ๐Ÿ”” Subscribe for more videos like this :
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ convert-comma-separated-string-to-array-using-javascript
JavaScript โ€“ Convert Comma Separated String To Array | GeeksforGeeks
November 26, 2024 - In pyspark SQL, the split() function converts the delimiter separated String to an Array. ร‚ It is done by splitting the string based on delimiters like spaces, commas, and stack them into an array.
๐ŸŒ
OneCompiler
onecompiler.com โ€บ javascript โ€บ 3xfqsme8y
convert a json array of objects to comma separated values - JavaScript - OneCompiler
Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc. var readline = require("readline") var rl = readline.createInterface({ input: process.stdin, output: process.stdout, terminal: false, }) rl.on("line", function (line) { console.log("Hello, " + line) }) ... An array is a collection of items or values.
Top answer
1 of 3
3

This can be achieved via the join() method which is built into the Array type:

const object = {
"id" : "122223232244",
"title" : "ื”ืชืจืขืช ืคื™ืงื•ื“ ื”ืขื•ืจืฃ",
"data" : ["ืขื•ื˜ืฃ ืขื–ื” 218","ืขื•ื˜ืฃ ืขื–ื” 217"]
}

/* Join elements of data array in object to a comma separated string */
const value = object.data.join();

console.log(value);

If no separator argument is supplied, then the join() method will default to use a comma separator by default.

Update

If the JSON was supplied in raw text via a string you can use the JSON.parse() method to extract an object from the JSON string value as a first step like so:

const json = `{"id" : "122223232244","title" : "ื”ืชืจืขืช ืคื™ืงื•ื“ ื”ืขื•ืจืฃ","data" : ["ืขื•ื˜ืฃ ืขื–ื” 218","ืขื•ื˜ืฃ ืขื–ื” 217"]}`

/* Parse input JSON string */
const object = JSON.parse(json);

/* Join elements of data array in object to a comma separated string */
const value = object.data.join();

console.log(value);

2 of 3
3

Access object properties using dot notation (e.g. obj.data) and then on the array you can use join to convert to a string with a comma in between.

const obj = {
    "id" : "122223232244",
    "title" : "ื”ืชืจืขืช ืคื™ืงื•ื“ ื”ืขื•ืจืฃ",
    "data" : ["ืขื•ื˜ืฃ ืขื–ื” 218","ืขื•ื˜ืฃ ืขื–ื” 217"]
}

console.log(obj.data.join(', '))

๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ faq โ€บ how-to-convert-comma-separated-string-into-an-array-in-javascript.php
How to Convert Comma Separated String into an Array in JavaScript
The following example demonstrates how to convert a comma separated string of person name into an array and retrieve the individual name using JavaScript.
๐ŸŒ
W3docs
w3docs.com โ€บ javascript
How to Convert a Comma-Separated String into Array
Use a comma separator in the first argument of the split method if you want to split it by comma: ... Use the limit parameter to split a string into an array and also get the individual name.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ javascript โ€บ convert-comma-separated-string-to-array-using-javascript
JavaScript - Convert Comma Separated String To Array - GeeksforGeeks
July 11, 2025 - The reduce() function builds an array by concatenating characters until a comma is encountered. You can manually process the string using loops and the slice() method to extract substrings.