- Published on
jq -r
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.
Example Usage
1. Without -r (default behavior)
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.