[jq] Check whether an object has a key

Created on November 30, 2026

Use has to test a single key in a JSON object. In this example, has("name") returns true because the object has a name key.

echo '{"name":"Taro","age":20}' | jq 'has("name")'
true

If the key is absent, has returns false. Use keys when you need the full list of keys.

jq