jq del() : Delete Keys or Array Elements
jq del(path_expression) removes the keys or array elements selected by the path.
del() trims noisy API responses down to the fields a workflow step needs before emitting smaller JSON.
What it does
del(p) deletes whatever the path expression p selects: a single key like .meta, several via .a, .b, or array elements like .[0]. The rest of the structure is returned unchanged. It accepts only path expressions, not arbitrary filters.
Common usage
# drop a noisy field
jq 'del(.permissions)' repo.json
# delete multiple keys
jq 'del(.created_at, .updated_at)' repo.json
# delete matching array elements
jq 'del(.[] | select(.draft))' pulls.jsonFunctions
| Form | What it does |
|---|---|
| del(.key) | Remove one key |
| del(.a, .b) | Remove several keys |
| del(.[2]) | Remove an array element by index |
| del(.[] | select(c)) | Remove matching array elements |
Common errors in CI
"jq: error: Invalid path expression with result ..." means you passed a non-path filter to del(); del only accepts paths, so move logic into select inside the path. "jq: error: Cannot index null with \"key\"" means a parent in the path was null; the field you tried to delete did not exist.