pretty-print json

Show JSON indented and coloured, pick values out of it, from a file or a web request.

  • text
  • development

Steps

  1. jq . file.json

    the file, indented and coloured

  2. curl -s https://api.example.com/items | jq .

    a web answer, the same way

  3. jq '.items[0].name' file.json

    one value out of it

  4. jq -r '.items[].name' file.json

    a value from every item, as plain text

  5. python3 -m json.tool file.json

    without jq: indented by Python

Notes

  • jq is a package of its own on most systems: sudo apt install jq, brew install jq.

Commands used

  • jq
  • curl
  • python3

Each has a page in lore: lore jq opens it.