If a JSON object and stored into a variable, then use JSON stringify() method to convert the print object as JSON in JavaScript.
Example print object as JSON in JavaScript
Simple example code.
<!DOCTYPE html>
<html>
<body>
<script>
var obj = {a: "A100", b: "B100" }
var string = JSON.stringify(obj);
console.log(obj)
console.log(string)
</script>
</body>
</html
Output:
![JavaScript print object as JSON](https://i0.wp.com/tutorial.eyehunts.com/wp-content/uploads/2022/02/JavaScript-print-object-as-JSON.jpg?resize=335%2C147&ssl=1)
Do comment if you have any doubts or suggestions on this JS Object print topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version