jq Cheat Sheet/Read whole raw file as one string

Slurp plain text into one string value.

Section: Files, Slurp, and Streams

Read whole raw file as one string

bash
bash
cat notes.txt | jq -Rs '.'
Explanation

`-Rs` is useful when you need to embed or encode an entire file.

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 Files, Slurp, and Streams
Slurp inputs into one array
Read all JSON inputs and wrap them into an array.
OpenIn sheetbashsame section
Read raw lines as strings
Treat input as plain text lines instead of JSON.
OpenIn sheetbashsame section
Convert JSON lines into array
Turn multiple JSON documents into a single array.
OpenIn sheetbashsame section
Use streaming parser
Process large JSON incrementally as path/value events.
OpenIn sheetbashsame section
Include filename in results
Annotate output with the source file name.
OpenIn sheetbashsame section
Pretty-print JSON from stdin
Format JSON read from stdin with default pretty output.
OpenIn sheetbash1 tag match