Syntax highlighting for JSON
A simple function that generates syntax-highlighted HTML markup from JSON.
- Call
syntaxHighlight()
with your JSON object as an argument. - Set the resulting string as the
innerHTML
on the element where you want to display it. - Customize the colors in CSS using the classes
.string
,.number
,.boolean
,.null
and.key
.