jq is a powerful command-line tool used to read, filter, and format JSON data directly in the terminal. Since most modern APIs return data in JSON format, jq makes it easy to extract specific values, clean the output, and understand complex responses.
Installation Commands
Update Termux and install jq:
pkg update && pkg upgrade && pkg install jq -yVerify installation:
jq --versionUsage Commands
Format JSON output:
echo '{"name":"John","age":25}' | jqGet specific value from JSON:
echo '{"name":"John","age":25}' | jq '.name'Get multiple values:
echo '{"name":"John","age":25}' | jq '{name, age}'Parse API response:
http https://api.github.com/users/octocat | jqExtract data from API:
http https://api.github.com/users/octocat | jq '.login'Pretty print JSON file:
jq . file.json