[jq] Load JSON values from a file into an array with --slurpfile

Created on November 30, 2026

Use --slurpfile to parse the JSON values in a file and bind the resulting array to a variable. Save this example as users.json.

{"name":"Taro"}
{"name":"Hanako"}

Read every JSON value in the file into $users.

jq -n --slurpfile users users.json '$users'
[
  {
    "name": "Taro"
  },
  {
    "name": "Hanako"
  }
]

-n runs the filter without reading a separate JSON input stream.

jq