![](https://www.infallibletechie.com/wp-content/uploads/2022/06/Converting-circular-structure-to-JSON-Exception-in-JavaScript-1024x576.jpg)
Sample code to Reproduce the issue:
let obj = {};
obj.a = "A";
obj.b = obj;
console.log( JSON.stringify( obj ) );
![](https://www.infallibletechie.com/wp-content/uploads/2022/05/Converting20circular20structure20to20JSON20in20JavaScript.jpg)
JSON.stringify() method does not support the circular references. So we have to remove the circular references before converting the object to JSON.
Fix for the above code:
let obj = {};
let obj1 = { "value" : "B" };
obj.a = "A";
obj.b = obj1;
console.log( JSON.stringify( obj ) );
![](https://www.infallibletechie.com/wp-content/uploads/2022/05/Avoiding20Converting20circular20structure20to20JSON20in20JavaScript.jpg)