Published Feb 26, 2025
[
 
]
jq -r
is a command-line option for the jq
tool, which is used for processing JSON data. The -r
(or --raw-output
) flag tells jq
to output strings as raw text rather than JSON-encoded strings.
echo '{"name": "Alice"}' | jq '.name'
Output:
"Alice"
(Quotes remain because the output is still JSON-encoded) 2. With -r:
echo ‘{“name”: “Alice”}’ | jq -r ‘.name’ |
Output:
Alice
(No quotes, just raw text) When to Use -r
When you need plain text output (e.g., when storing results in a variable or passing them to another command).
When working with JSON data that includes URLs, filenames, or command outputs that should not be wrapped in quotes.