jq Arrays and Objects/Delete multiple paths

Remove several nested paths at once.

Section: Paths and Deep Updates

Delete multiple paths

bash
bash
echo '{"user":{"password":"secret","token":"abc","name":"alice"}}' | jq 'delpaths([["user","password"],["user","token"]])'
Explanation

Very useful for scrubbing sensitive fields.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Paths and Deep Updates
Read value by explicit path
Look up a nested value using a path array.
OpenIn sheetbashsame section
Set value by explicit path
Write a nested value using a path array.
OpenIn sheetbashsame section
Find all scalar paths
List paths that end in scalar values.
OpenIn sheetbashsame section
Get all leaf values
Return every scalar value in a document.
OpenIn sheetbashsame section
Find matching nested objects
Search recursively for objects containing a field.
OpenIn sheetbashsame section
First array item
Get the first element.
OpenIn sheetbash1 tag match