Command-line JSON processor.
Synopsis
jq [OPTIONS] FILTER [FILE...]
Description
Applies a jq FILTER expression to JSON input, transforming, filtering, or reshaping it, and prints the result.
Options
-R, --raw-input Read each line as a string instead of JSON.
-r, --raw-output Output strings without quotes.
-c, --compact-output Compact instead of pretty-printed output.
-e, --exit-status Set exit status based on output.
-s, --slurp Read entire input into one array.
-n, --null-input Don't read any input.
-j, --join-output Don't print newlines after each output.
-a, --ascii Force ASCII output.
-S, --sort-keys Sort object keys.
--tab Use tabs for indentation.
--arg NAME VALUE Bind $NAME to the string VALUE.
--argjson NAME JSON Bind $NAME to the JSON-decoded value JSON.
--rawfile NAME FILE Bind $NAME to the raw contents of FILE.
--slurpfile NAME FILE Bind $NAME to the array of JSON values in FILE.
--args Remaining arguments are string positional args ($ARGS.positional).
--jsonargs Remaining arguments are JSON positional args ($ARGS.positional).
Examples
$ curl -s https://api.example.com/data | jq '.items[0].name'
Extract a field from a JSON API response.
$ jq -r '.[] | .id' data.json
Print a raw list of ids from a JSON array.
$ jq -n --arg x hello '$x'
Build JSON output from shell values.
Notes
-C/--color and -M/--monochrome are accepted but colorization is ignored in this shell's output.
See Also
grep, awk, sed