Standard built-ins

JSON.stringify()

Try the free JavaScript compiler

Serialize supported data into JSON text; omit certain object values, replace unsupported array entries with null, reject cycles and ordinary BigInt. Root unsupported values may return undefined.

Formal Syntax & Structure

javascript syntaxjavascript
JSON.stringify(value, [replacer], [space])

Parameters & Attributes

NameTypeDescription
valueAnyValue to associate or insert.
replacerFunction | Array | nullOptional transform or property names.
spaceNumber | StringOptional indentation.

Return Value

String | undefined

JSON text or undefined.

Working Example

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