jq -r : Raw Output Without JSON Quotes
The jq -r flag prints string results raw, without the surrounding double quotes JSON would normally add.
Capturing a value into a shell variable almost always needs -r so the variable does not carry literal quote characters in CI.
What it does
-r (--raw-output) makes jq emit string results verbatim instead of as quoted JSON strings. Non-string outputs (numbers, objects, arrays) are still printed as JSON. It affects only top-level string outputs, not strings nested inside an object.
Common usage
# capture a clean value into a shell variable
NAME=$(gh api repos/cli/cli --jq '.name')
SHA=$(jq -r '.commit.sha' build.json)
# raw lines to loop over
jq -r '.[].name' tags.json | while read -r t; do echo "$t"; doneFlags
| Flag | What it does |
|---|---|
| -r, --raw-output | Print strings without quotes |
| -j, --join-output | Like -r but no trailing newline |
| --raw-output0 | NUL-separate raw outputs |
| -R, --raw-input | The input side equivalent |
In CI
Without -r a captured value becomes "v1.2.3" including the quotes, which breaks string comparisons and path building downstream. Use -j when you need the output with no trailing newline, for example before piping into base64.
Common errors in CI
-r is not an error source itself; the usual bug is a value that still has quotes because -r was on the outer jq but the string is nested inside an object jq still renders as JSON. Project the string to the top level, or it stays quoted.