score:1

Accepted answer

parse your string to js object, than parse it to string to with new lines.

console.log(json.stringify(json.parse('{\"a": 1, \"b\":\"2\"}'), null, 2));

score:0

before just running below code you should make a small change.

"{\"a": 1, \"b\":\"2\"}" ->
"{\"a\": 1, \"b\":\"2\"}"

const stringifiedjson = "{\"a\": 1, \"b\":\"2\"}";
const result = json.parse(json);
console.log(result);

Related Query

More Query from same tag