semikolan;

Til ; ;1 min read

Pretty-print JSON in one shell pipe #

curl -s url | python -m json.tool — no jq required for a quick look.

When you just want to read an API response and don’t feel like installing anything:

bash
curl -s https://api.example.com/thing | python -m json.tool

python -m json.tool ships with every Python install and pretty-prints stdin. No jq, no dependencies. Here’s the whole thing, command and output:

bash
$ echo '{"name":"ada","langs":["go","rust"]}' | python -m json.tool
{
    "name": "ada",
    "langs": [
        "go",
        "rust"
    ]
}

For anything more than eyeballing — filtering, reshaping — reach for jq. For a quick look, this is already on your machine.


EOF
filed undershelljson