Before I paste a config file into a forum post or a GitHub issue, I want the secrets gone, and doing that by hand in an editor is how a token slips through. jq has a builtin for it, del(), which removes a key and its value and prints the rest of the JSON.
jq 'del(.password)' config.json
That prints config.json without the top-level password key. The argument is a path, so nested keys work, and you can list more than one with a comma:
jq 'del(.db.password, .smtp.token)' config.json > config.shared.json
Now config.shared.json has everything except those two values, and the original stays as it was. Arrays work the same way with an index: the manual’s example del(.[1, 2]) on ["foo", "bar", "baz"] leaves just ["foo"].
I’d reach for this for the JSON settings files that many self-hosted apps keep in their appdata folder, something like /mnt/user/appdata/<app>/config.json, when you want to show someone your setup without your API keys.
The caveat is about the shell. jq never changes the file, it writes to standard output. So don’t try jq 'del(.password)' config.json > config.json: the shell empties config.json before jq even reads it, and you’re left with nothing. Write to a new file and move it over the old one if that’s what you want. And check the result before you share it, because del() only removes the keys you name. A secret under a key you forgot, or inside a URL string, is still in there.
Further reading: jq 1.8 manual