How to convert JSON to JavaScript object

In this shot, we will learn how to convert a JSON string into a JavaScript object.

Syntax

JSON.parse(JSONstring)

Where JSONstring is the JSON string to parse. This method returns a JavaScript object.

JSON.parse(JSONstring) will raise an error if the passed string is not in a valid JSON format.

Code

Suppose you have a string JSON such as:

'{ "name": "John", "age": 20, "isYoung": true}'

To convert the above string into a JavaScript object, run:

let stringJSON = '{ "name": "John", "age": 20, "isYoung": true}';
let object = JSON.parse(stringJSON);
console.log(object);

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved