JavaScript 2025 · Objects and data
Convert to and from JSON
Pretty-print an object as JSON, and parse JSON text back.
const text = JSON.stringify(data, null, 2);
const parsed = JSON.parse(text);
Official JavaScript 2025 documentation
JavaScript 2025 · Objects and data
Pretty-print an object as JSON, and parse JSON text back.
const text = JSON.stringify(data, null, 2);
const parsed = JSON.parse(text);
Official JavaScript 2025 documentation
Was this page helpful?