How can I display JSON in an easy-to-read (for human readers) format? I'm looking primarily for indentation and whitespace, with perhaps even colors / font-styles / etc.
JavaScript JSON – How to Pretty-Print JSON Using JavaScript
javascriptjsonpretty-print
Best Answer
Pretty-printing is implemented natively in
JSON.stringify()
. The third argument enables pretty printing and sets the spacing to use:If you need syntax highlighting, you might use some regex magic like so:
See in action here: jsfiddle
Or a full snippet provided below: