RSRobince Studio

Working with JSON

JSON is a text format for sharing data. JavaScript gives you two helpers to move between objects and JSON strings.

  • JSON.stringify turns an object into a JSON string
  • JSON.parse turns a JSON string back into an object
const obj = { name: "Ada", skills: ["js", "html"] };
const text = JSON.stringify(obj);
const back = JSON.parse(text);
Pass a third argument to JSON.stringify, such as 2, to pretty-print with indentation.
Try it yourself

Loading editor…