JavaScript – Convert Array to JSON String
To convert an array to JSON string in JavaScript, call JSON.stringify() method and pass the array as argument.
Syntax
The syntax to call JSON.stringify() method with array arr
passed as argument is
JSON.stringify(arr)
stringify() returns a string value.
ADVERTISEMENT
Examples
In the following example, we take an array arr
with strings as elements and convert this array to JSON string using JSON.stringify() method.
index.html
Conclusion
In this JavaScript Tutorial, we learned how to convert an array into JSON string in JavaScript using JSON.stringify() method, with examples.