Javatpoint Logo
Javatpoint Logo

JavaScript JSON.stringify() method

The JavaScript JSON.stringify() method converts a JavaScript value to a JSON string. It replaces values if a replacer function is specified or includes only the specified properties if a replacer array is specified.



value: The value to convert to a JSON string.

Replacer: A function that alters the behavior of the stringification process. It is optional.

space: A String or Number object that's used to insert white space into the output JSON string for readability purposes. It is optional.

Return value

A JSON string representing the given value.

Browser Support

Chrome Yes
Safari 4
Firefox 3.5
Opera 10.5

JavaScript JSON.stringify() method Examples

Example 1

Let's see an example to convert an object of string to JSON string.

Test it Now



Example 2

Let's see an example to convert an array object to JSON string.

Test it Now


Next TopicJavaScript JSON

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA