The Array.prototype.join() method:

var arr = ["Zero", "One", "Two"];

document.write(arr.join(", "));
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Answer from Wayne on Stack Overflow
🌐
Reddit
reddit.com › r/javascripttips › how do i convert an array to a string with commas in javascript
r/JavaScriptTips on Reddit: How do I convert an array to a string with commas in JavaScript
April 13, 2023 -

In JavaScript, you can convert an array to a string with commas using the join()
method.

The join() method returns a string that concatenates all the elements of an array, separated by the specified separator, which in this case is a comma.

Here is an example:

const array = ['apple', 'banana', 'orange'];
const string = array.join(', ');
console.log(string); 

// output: "apple, banana, orange"

In this example, we first define an array of three fruits. Then we use the join()
method with a comma and a space as the separator to create a string that lists all the fruits with a comma and a space between each one.

You can replace the comma and space separator with any other separator you like, such as a hyphen, a semicolon, or a newline character.

It's important to note that the join() method only works on arrays, and it will throw an error if you try to use it on any other type of object.

Click here to learn more ways to Convert Array to String with Commas in JS

array.join vs. array.toString Jul 25, 2017
r/learnjavascript
9y ago
Comma operator in JavaScript Oct 26, 2025
r/learnjavascript
9mo ago
How to take an array and format it as a string. Apr 28, 2022
r/learnjavascript
4y ago
More results from reddit.com
Discussions

jquery - Array to string containing comma's - JavaScript - Stack Overflow
Ok so I'm writing a script that includes whole sentences, but whole sentences can contain comma's. Due to the way the script works the array has to be turned into a string at least once. So when t... More on stackoverflow.com
🌐 stackoverflow.com
javascript - How to convert object array to comma separated string? - Stack Overflow
Im trying to convert at object array with jQuery or javascript to a comma separated string, and no matter what I try I can´t get it right. I have this from a select value. ort = $('#ort').val(); ... More on stackoverflow.com
🌐 stackoverflow.com
How do I convert an array to a string with commas in JavaScript
...you get a better, more thorough explanation here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join More on reddit.com
🌐 r/JavaScriptTips
1
4
April 13, 2023
How to convert a comma-separated string into JS array?
let array = 'string'.split(','); Edit: MDN Documentation More on reddit.com
🌐 r/learnjavascript
1
2
August 4, 2020
🌐
Medium
medium.com › coding-at-dawn › how-to-convert-an-array-to-a-string-with-commas-in-javascript-79e212506c2
How to Convert an Array to a String with Commas in JavaScript | by Dr. Derek Austin 🥳 | Coding at Dawn | Medium
January 5, 2023 - One of JavaScript’s most helpful built-in array methods is .join() (Array.prototype.join()), which returns a string primitive. “The join() method creates and returns a new string by concatenating all of the elements in an array (or an array-like object), separated by commas or a specified separator string.” — MDN Docs
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › create-a-comma-separated-list-from-an-array-in-javascript
Create a Comma Separated List from an Array in JavaScript - GeeksforGeeks
July 11, 2025 - The code uses map(String) to convert each element of the array arr into a string, and then join(',') joins these string elements with commas. The result is a comma-separated string "1,2,3,4,5", which is logged to the console.
🌐
SourceFreeze
sourcefreeze.com › home › how to convert array to comma separated strings in javascript
How to convert array to comma separated strings in javascript
March 21, 2023 - Please refer to the below example ... console.log(typeof strValue); // string · Alternatively, we can use the Array.prototype.join() method, this Array.join() method is used to join() the all the array with the specified ...
Find elsewhere
🌐
ItSolutionstuff
itsolutionstuff.com › post › javascript-convert-array-into-comma-separated-string-exampleexample.html
Javascript Convert Array into Comma Separated String Example - ItSolutionstuff.com
July 6, 2023 - After i search on google i find out way to convert object array to comma separated string two way in javascript. we can do it using toString() and join() function of array property.
🌐
Vultr Docs
docs.vultr.com › javascript › standard-library › Array › toString
JavaScript Array toString() - Convert Array to String | Vultr Docs
September 27, 2024 - Use the toString() method to convert this numeric array into a string. ... const numbers = [1, 2, 3, 4, 5]; const result = numbers.toString(); console.log(result); Explain Code · The output from this snippet will be 1,2,3,4,5. The toString() ...
🌐
Javascriptf1
javascriptf1.com › snippet › convert-array-to-comma-separated-string-using-javascript
Convert array to comma separated string using JavaScript - JavaScriptF1.com
June 18, 2022 - The easiest way to create CSV text from a plain array is to use the toString method or the String constructor in JavaScript. The advantage of the String constructor is that you do not have to check if the variable is indeed an array.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › join
Array.prototype.join() - JavaScript - MDN Web Docs
The join() method of Array instances returns a new string that is the concatenation of all elements in this array, separated by commas or a specified separator string. If the array has only one item, that item's stringification is returned without using the separator.
🌐
TutorialsPoint
tutorialspoint.com › how-to-turn-javascript-array-into-the-comma-separated-list
How to turn JavaScript array into the comma-separated list?
November 25, 2022 - The toString() method simply converts all the elements of the array into a string and then return that string in the form of a comma-separated list which contains all the elements that contained by the original array.
🌐
OneCompiler
onecompiler.com › javascript › 3uaemw5yq
Convert Javascript string array comma separated string
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.
🌐
Codetogo
codetogo.io › how-to-convert-array-to-comma-separated-string-in-javascript
How to convert array to comma separated string in JavaScript | Code to go
December 18, 2017 - How to convert array to comma separated string in JavaScript, Array.join modern JavaScript answer on Code to go
🌐
Tutorial Reference
tutorialreference.com › javascript › examples › faq › javascript-how-to-convert-array-to-comma-separated-string
How to Convert an Array to a Comma-Separated String in JavaScript | Tutorial Reference
This guide will teach you how to use the join() method to convert an array to a string with any separator you need. You will also learn the best practices for handling empty or unwanted values to ensure your output is clean and predictable. The join() method is the definitive tool for this job.
🌐
W3Resource
w3resource.com › javascript-exercises › fundamental › javascript-fundamental-exercise-5.php
JavaScript fundamental (ES6 Syntax): Convert an array of objects to a comma-separated values (CSV) string that contains only the columns specified - w3resource
July 3, 2025 - Use Array.prototype.join('\n') to combine all rows into a string. Omit the third argument, delimiter, to use a default delimiter of,. ... // Source: https://bit.ly/2neWfJ2 // Define a function called `JSON_to_CSV` that converts JSON data to ...
🌐
CoreUI
coreui.io › answers › how-to-convert-an-array-to-a-string-in-javascript
How to convert an array to a string in JavaScript · CoreUI
May 19, 2026 - Use the join() method to convert an array into a string with a specified separator.
🌐
Medium
medium.com › @setyawan_asep › how-to-convert-array-of-objects-into-comma-separated-string-extracting-only-one-property-ff26cfcad00e
How to Convert Array of Objects into Comma Separated String extracting only one property | by asep setyawan | Medium
March 8, 2018 - I’d like to share a quick solution which always is really useful when you are handling complex object-type data structures in JavaScript / ES6 / TypeScript. That code will be useful when you want to extract some property values from an array of objects.