On this page
  1. JSON.stringify
  2. Signature & Overview
  3. Notes & Pitfalls
  4. Example

JSON.stringify

Prev: parse | Up: JSON | Next: Reflect
Rel: JSON, JSON, Math, BigInt & Date Guide
Ref: MDN Web Docs — JSON.stringify
Tags: #public #web #javascript #builtins #json #tier/core


Signature & Overview

JSON.stringify(value, replacer?, space?)

Serializes a JavaScript value to a JSON string (pass space = 2 for pretty-printing).

Notes & Pitfalls

Example

const pretty = JSON.stringify({ a: 1, b: undefined, c: [2, 3] }, null, 2);
console.assert(pretty.includes('"a": 1') && !pretty.includes('"b"'));

Linked from

Related notes