How can I pretty-print JSON in a shell script?

Is there a (Unix) shell script to format JSON in human-readable form?

Basically, I want it to transform the following:

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

… into something like this:

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

60
60

Leave a Comment