How to covert JavaScript object to JSON string?

This short article is about how to convert a JavaScript object into a JSON string.

In JavaScript, to covert an object into a JSON string we can use the JSON.stringify() method.

The JSON.stringify() method is used to take an object and transform it into a JSON string.



Let's check the use of JSON.stringify() with an example.

let obj = { name: 'Johnny', id: 5554, city: 'London' }
const jsonStr = JSON.stringify(obj)




Related Topics:

Difference Between JSON.Stringify() And JSON.Parse() In JSON

How to convert a JSON string into a JavaScript object

Beautify or pretty print JSON programmatically in JavaScript

💾 Recommended Articles