jq - raw output to eliminate double quotes

by
Jeremy Canfield |
Updated: August 05 2025
| jq articles
Let's say my.json contains the following, where there are a few keys.
{
"fruits": [
"apple",
"banana",
"grapes"
],
"veggies": [
"onion",
"pepper",
"carrot"
],
"grains": [
"rice",
"couscous",
"quinoa"
]
}
Index numbers can be used to return a specific key. Notice in this example that the output is wrapped in double quotes.
]$ jq 'keys[0]' my.json
"fruits"
The -r or --raw-output flag can be used so that the output does not include double quotes.
~]$ jq --raw-output 'keys[0]' my.json
fruits
Did you find this article helpful?
If so, consider buying me a coffee over at