Turn raw text into a valid JSON string.
Section: Encoding and Recursion
JSON-encode raw text
bash
bash
printf 'hello
world
' | jq -Rs '.'Explanation
Excellent for embedding arbitrary text into JSON payloads.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Encoding and Recursion