Standard built-ins

JSON.parse()

Try the free JavaScript compiler

Parse JSON text to JavaScript values. Invalid text throws SyntaxError. Optional reviver transforms values bottom-up. Validate expected data shape separately.

Formal Syntax & Structure

javascript syntaxjavascript
JSON.parse(text, [reviver])

Parameters & Attributes

NameTypeDescription
textStringJSON text.
reviverFunctionOptional transform after parsing.

Return Value

Any

Parsed or revived value.

Working Example

Example Snippetjavascript
console.log(JSON.parse('{"n":3}').n);
JavaScript Reference