How to parse a JSON string into an object and serialize (stringify) an object back to JSON in Node.js. Node.js exposes the same global JSON.parse/JSON.stringify as the browser; .json files can be require()d or imported directly. Need to clean up the JSON first? Use the formatter & validator.
// built in, no import needed
const obj = JSON.parse(text);
// or read a file:
const obj2 = require('./data.json');
const text = JSON.stringify(obj, null, 2);
Node.js exposes the same global JSON.parse/JSON.stringify as the browser; .json files can be require()d or imported directly. Parse with the snippet above; the result is a native object/map you can read.
Use the stringify snippet above with indentation, or paste your JSON into the formatter on this page.