jq in Termux – Installation & Usage Commands

jq in Termux – Installation & Usage Commands

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 -y

Verify installation:

jq --version

Usage Commands

Format JSON output:

echo '{"name":"John","age":25}' | jq

Get 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 | jq

Extract data from API:

http https://api.github.com/users/octocat | jq '.login'

Pretty print JSON file:

jq . file.json
SHARE THIS POST: