The method array.toString() actually calls array.join() which result in a string concatenated by commas. ref

var array = ['a','b','c','d','e','f'];
document.write(array.toString()); // "a,b,c,d,e,f"
Run code snippetEdit code snippet Hide Results Copy to answer Expand

Also, you can implicitly call Array.toString() by making javascript coerce the Array to an string, like:

//will implicitly call array.toString()
str = ""+array;
str = `${array}`;

Array.prototype.join()

The join() method joins all elements of an array into a string.

Arguments:

It accepts a separator as argument, but the default is already a comma ,

str = arr.join([separator = ','])

Examples:

var array = ['A', 'B', 'C'];
var myVar1 = array.join();      // 'A,B,C'
var myVar2 = array.join(', ');  // 'A, B, C'
var myVar3 = array.join(' + '); // 'A + B + C'
var myVar4 = array.join('');    // 'ABC'

Note:

If any element of the array is undefined or null , it is treated as an empty string.

Browser support:

It is available pretty much everywhere today, since IE 5.5 (1999~2000).

References

  • ECMA Specification
  • Mozilla
  • MSDN
Answer from Victor on Stack Overflow
🌐
GitHub
github.com › bobbyhadz › javascript-convert-array-to-comma-separated-string
GitHub - bobbyhadz/javascript-convert-array-to-comma-separated-string: A repository for an article at https://bobbyhadz.com/blog/javascript-convert-array-to-comma-separated-string · GitHub
A repository for an article at https://bobbyhadz.com/blog/javascript-convert-array-to-comma-separated-string - bobbyhadz/javascript-convert-array-to-comma-separated-string
Author   bobbyhadz
Discussions

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
Create comma separated string from array
Hi all, I have a HTTP module that returns an array of collections with values including a name, description and number. Rough response is: items: [ { name: name 1, description: description1, number: number 1 }, … More on community.make.com
🌐 community.make.com
3
0
March 24, 2024
[javascript] how to effectively convert string to array while removing commas and the space at the beginning/end if there was any?
Trim after the split with map, so str.split(",").map((s) => s.trim()) Much easier to read than regex imo More on reddit.com
🌐 r/webdev
7
1
September 14, 2021
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
🌐
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

🌐
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 - To convert array to comma separated strings in Javascript need to pass array to the String object like String(arr) or join() method the Array.join() method returned the comma separated strings as an output
🌐
OneCompiler
onecompiler.com › javascript › 3uaemw5yq
Convert Javascript string array comma separated string
let arrayName = [value1, value2,..etc]; // or let arrayName = new Array("value1","value2",..etc);
Find elsewhere
🌐
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 ...
🌐
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.
🌐
GitHub
github.com › bazaarvoice › jolt › issues › 784
Convert one property of an array into a comma separated string · Issue #784 · bazaarvoice/jolt
April 9, 2019 - Hi, I need to convert the names in the tags array into a comma separated string set as tag. Input: tags : [ { "id" : "1", "name": "mobile", "slug": "" }, { "id" : "2", "name": "smart phone", "slug": "" }, { "id" : "3", "name": "light-wei...
Author   bazaarvoice
🌐
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 custom separators in JavaScript efficiently.
🌐
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.
🌐
ServiceNow Community
servicenow.com › community › developer-forum › convert-array-string-to-comma-separated-string › m-p › 2606171
Convert Array String to Comma Separated String - ServiceNow Community
July 6, 2023 - (function execute(inputs, outputs) { var mrvs; var itemID = inputs.record_sysid; var ritmGR = new GlideRecord('sc_req_item'); if (ritmGR.get(itemID)) { mrvs = ritmGR.variables[inputs.variable_set_name]; } var mrvSort = JSON.parse(mrvs); var sortedArray = mrvSort.sort(function(a, b){ var x = a[inputs.variable_to_sort]; var y = b[inputs.variable_to_sort]; return x < y ? -1 : x > y ? 1 : 0; }); outputs.sorted_mrv_array = JSON.stringify(sortedArray); })(inputs, outputs);
🌐
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() ...
🌐
Altcademy
altcademy.com › blog › how-to-convert-array-to-string-in-javascript
How to convert array to string in JavaScript - Altcademy.com
August 29, 2023 - Another way to convert an array to a string in JavaScript is by using the toString() method. This method converts an array into a string, with array elements separated by commas.
🌐
Make Community
community.make.com › questions
Create comma separated string from array - Questions - Make Community
March 24, 2024 - Hi all, I have a HTTP module that returns an array of collections with values including a name, description and number. Rough response is: items: [ { name: name 1, description: description1, number: number 1 }, { name: name 2, description: description2, number: number 2 }, { name: name 3, description: description3, number: number 3 }, ] I want to extract those values for each collection and create a comma separated string in the format of name1 | description1 | number1, name2...
🌐
GitHub
github.com › wooorm › comma-separated-tokens
GitHub - wooorm/comma-separated-tokens: Parse and stringify comma-separated tokens
Serialize an array of strings or numbers (Array<string|number>) to comma-separated tokens (string).
Author   wooorm
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › join
Array.prototype.join() - JavaScript - MDN Web Docs
Array.prototype.join recursively converts each element, including other arrays, to strings. Because the string returned by Array.prototype.toString (which is the same as calling join()) does not have delimiters, nested arrays look like they are flattened. You can only control the separator of the first level, while deeper levels always use the default comma.
🌐
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.