What does jq do?

command-line JSON processor (apply a filter to JSON input).

▸ Explain your own jq command →

jq examples, explained

$ jq -r '.items[] | select(.age > 30) | .name' data.json

  • jqcommand-line JSON processor (apply a filter to JSON input)
  • -rraw output — print strings without JSON quotes
  • .items[] | select(.age > 30) | .namejq filter: iterate over each element of .items, then keep only items where .age > 30, then get field .name
  • data.jsonan argument passed to the command

jq flags & options

-rraw output — print strings without JSON quotes
-jraw output with no trailing newline between results
-ccompact output — one JSON result per line
-ndon't read input; use null as the input
-sslurp — read the whole input stream into one array
-Rread raw input — each line becomes a JSON string
-eset the exit code from the last output (for scripting)
-Ssort object keys in the output
-aoutput non-ASCII characters as \uXXXX escapes
-fread the filter program from a file
-argdefine a string variable: --arg name value
-argjsondefine a JSON variable: --argjson name json
-tabindent the output with tabs

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.