Skip to content

Convert the object to JSON JavaScript | Example code

  • by

Use the JSON stringify() method to easily convert a JavaScript object into a JSON string. This method in JavaScript allows us to take a JavaScript object or Array and create a JSON string out of it.

Example convert an object to JSON JavaScript

Simple example code.

<!DOCTYPE html>


    var obj = { "Name":"John", "Age":50, "City":"New York"};
    var myJSON = JSON.stringify(obj);





Convert the object to JSON JavaScript

Do comment if you have any doubts or suggestions on this JS JSON object topic.

Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *