JavaScript JSON.parse() Method
The JSON.parse() static method reads a string of JSON text and turns it into the JavaScript value it describes, such as an object or array.
Description
The JSON.parse() static method parses a JSON string and returns the JavaScript value it describes. It is how you read JSON received from a server, from localStorage or from a file.
JSON syntax is stricter than JavaScript: keys and strings must use double quotes, and trailing commas and comments are not allowed. Invalid input throws a SyntaxError, so wrap calls on untrusted data in try...catch.
The optional reviver function lets you transform values as they are parsed, for example to turn date strings back into Date objects. When working with fetch(), the response's json() method parses the body for you.
Syntax
JSON.parse(text)
JSON.parse(text, reviver)Parameters
- textThe string to parse as JSON.
- reviverOptional. A function called for each key and value, which can change a value before it is returned.
Return Value
The object, array, string, number, boolean or null that the JSON text represents.
Exceptions
- SyntaxErrorThrown if the string is not valid JSON.
Example
Browser Support
The following information will show you the current browser support for the JSON.parse() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





