The default redis-cli output is made for people: numbered lists, quotes, type hints. Once you pipe it into another tool, you end up parsing text. Newer redis-cli versions can just print JSON.
redis-cli --json HGETALL user
The usage text lists --json as “Output in JSON format (default RESP3, use -2 if you want to use with RESP2)”. That RESP detail changes the shape of the result. In a throwaway instance with a hash called user (fields name and city), redis-cli 7.0.15 printed:
redis-cli --json HGETALL user
{"name":"Anna","city":"Leiden"}
redis-cli -2 --json HGETALL user
["name","Anna","city","Leiden"]
With RESP3 you get an object, with RESP2 a flat list of alternating names and values. A missing key printed null.
redis-cli --json HGETALL user | jq -r .city
jq takes it from there. Lists work the same way: redis-cli --json LRANGE mylist 0 -1 | jq -r '.[1]' printed the second element, including one with a space in it.
There is also --quoted-json, which the help describes as the same thing with ASCII-safe quoted strings instead of Unicode. And --csv for spreadsheet-style output. The docs say --csv works on a single command only, not as an export of a whole database. Neither option replaces a proper backup.
Caveat: check that your redis-cli has the option before putting it in a script. redis-cli --help | grep json shows it on 7.0.15, the version used above.
Further reading: Redis CLI: usage and CSV output