Skip to content

Convert string to JSON JavaScript | Example code

  • by

JSON is used to exchange data to/from a web server in string format. Receiving data from a web server is always a string. Use JSON parse() method convert string to JSON JavaScript.


Example convert string to JSON JavaScript

Simple example code. Make sure the string is in JSON format.

<!DOCTYPE html>

    var msg = '{"name":"Tim", "age":30, "city":"Bangalore"}'

    var jsonData = JSON.parse(msg);




Convert string to JSON JavaScript

Do comment if you have any doubts or suggestions on this JS string to JSON 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 *