This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

Create a JSON string from a JavaScript array.

// declare JavaScript array
const arr = ["John", "Peter", "Sally", "Jane"];

// convert JS array to JSON string
const myJSON = JSON.stringify(arr);
document.getElementById("demo").innerHTML = myJSON;

You will learn how to send a JSON string to a server in the next chapters.