View My JSON
Skip to main content
Blog

How to pretty print JSON in JavaScript, Python, and the shell

Pretty print JSON with JSON.stringify, Python, jq, or a browser tool. Covers indentation choices, key order, Unicode output, and common pitfalls.

APIs and logging libraries emit JSON in its smallest form, which is perfect for machines and miserable for people. Pretty printing adds line breaks and indentation so you can see the nesting. It takes one line in most languages, but there are details around indentation, key order, and non-ASCII text that are worth knowing before you start copying output into pull requests.

Sources and further reading

Try the JSON workspace