How to Pretty-print JSON in a shell script

To pretty print JSON in a shell, we can use Python json module.

For example

echo '{"foo": "lorem", "bar": "ipsum"}' | python3 -m json.tool

{
    "foo": "lorem",
    "bar": "ipsum"
}

or get json from the Internet

curl https://github.com/manifest.json | python3 -m json.tool