Introduction
In JavaScript, there are situations when we wish to pretty-print JSON. In this article, we'll look at how to do it.
How to pretty-print JSON using JavaScript
To pretty-print JSON using JavaScript we can use JSON.stringify()
function:
The output:
The JSON.stringify()
method converts a JavaScript value to a JSON string, and give us opportunity to format that output string.
Conclusion
In this post, we presented the best way to pretty-print JSON using JavaScript.
{{ 'Comments (%count%)' | trans {count:count} }}
{{ 'Comments are closed.' | trans }}