| . | identity — pass input through unchanged |
| .foo | field access on object {"foo":"bar"} → "bar" |
| .foo.bar | nested field access |
| .["foo"] | bracket notation (for special chars / vars) |
| .foo? | optional operator — suppress errors if missing |
| .foo // "default" | alternative operator (use if null or false) |
| .[0] | first element |
| .[-1] | last element |
| .[2:5] | slice — index 2 up to (not incl.) 5 |
| .[] | explode array — emit each element separately |
| .[1:] | slice from index 1 to end |
| length | length of array, string, or object |
| . | .foo | pipe — chain filters |
| {a: .x, b: .y} | construct new object |
| {(.key): .val} | computed key in object construction |
| [.[] | .name] | collect into array |
| ., .foo | comma — produce multiple outputs |
| empty | produce no output (useful in conditionals) |
| map(.x) | apply filter to each element → array equivalent to [.[] | .x] |
| map_values(.x) | apply to values of object or array |
| select(cond) | keep element only if condition is true |
| map(select(.n > 2)) | filter array by condition |
| to_entries | object → [{key, value}] |
| from_entries | [{key, value}] → object |
| with_entries(f) | to_entries | map(f) | from_entries |
| add | sum array / concatenate strings or arrays |
| any | true if any element is truthy |
| all | true if all elements are truthy |
| any(cond) | any element satisfies condition |
| all(cond) | all elements satisfy condition |
| min_by(.x) / max_by(.x) | min/max element by key |
| group_by(.x) | group elements by key → array of arrays |
| unique / unique_by(.x) | deduplicate array |
| sort / sort_by(.x) | sort array |
| flatten / flatten(n) | flatten nested arrays (to depth n) |
| reduce .[] as $x (0; .+$x) | reduce with accumulator reduce EXPR as $var (INIT; UPDATE) |
| "\(.foo) bar" | string interpolation |
| split(",") | split string → array |
| join(",") | join array of strings |
| ltrimstr("x") | trim prefix if present |
| rtrimstr("x") | trim suffix if present |
| startswith("x") | test prefix |
| endswith("x") | test suffix |
| ascii_downcase | lowercase string |
| test("regex") | test string against regex → bool |
| match("regex") | match object with captures |
| capture("(?<n>...)") | named captures → object |
| gsub("x";"y") | global substitution |
| type | return type as string "null" "boolean" "number" "string" "array" "object" |
| arrays | select only array values |
| objects | select only object values |
| strings | select only string values |
| numbers | select only number values |
| nulls | select null values |
| tostring | convert to string (JSON-encode if not string) |
| tonumber | parse string as number |
| tojson | encode value as JSON string |
| fromjson | parse JSON string → value |
| keys | sorted array of object keys |
| keys_unsorted | object keys, insertion order |
| values | array of object values |
| has("key") | test if key/index exists |
| in(obj) | test if input is a key in obj |
| contains(val) | recursive containment check |
| if A then B else C end | conditional (else is required) |
| if A then B elif C then D else E end | chained conditions |
| not | boolean negation |
| == != < <= > >= | comparison operators |
| and or | boolean operators |
| .x as $v | ... | bind value to variable |
| label-break | label $out | ... , break $out |
| try EXP catch EXP | catch errors (. = error message in catch) |
| error("msg") | raise an error |
| def f(x): ...; | define a function def addtwo: . + 2; 5 | addtwo → 7 |
| path(.a.b) | path expression → ["a","b"] |
| getpath(["a","b"]) | get value at path array |
| setpath(["a"]; val) | set value at path |
| delpaths([["a","b"]]) | delete paths |
| del(.foo) | delete a key from object or element from array |
| [paths] | all paths in the input |
| [leaf_paths] | paths to leaf (scalar) values only |
| .. | .foo? | recursive descent — search all levels |
| .foo |= . + 1 | update field in place |
| .foo += 1 | arithmetic update shorthand |
| .foo -= 1 | subtract update |
| .a |= del(.b) | delete nested key |
| + { "x": 1 } | merge object (right wins on conflict) |
| - ["x"] | array subtraction (remove elements) |
| .[] |= select(. > 2) | filter array in place |
| -r / --raw-output | print strings without JSON quotes | $ jq -r '.Name' |
| -c / --compact-output | output on single line (no pretty-print) | $ jq -c '.' |
| -s / --slurp | read all inputs into one array | $ cat *.json | jq -s '.' |
| -n / --null-input | no input — use null as input (good for constructing JSON) | $ jq -n '{a:1}' |
| -R / --raw-input | read each line as a raw string | |
| --arg name val | bind shell string to jq variable $name | $ jq --arg k "mykey" '.[$k]' |
| --argjson name val | bind JSON value to jq variable $name | $ jq --argjson n 42 'select(. > $n)' |
| --slurpfile name f | bind contents of file to $name (as array) | |
| -e / --exit-status | exit 1 if last output is false/null (useful in scripts) | |
| -f file | read filter from file instead of arg | $ jq -f filter.jq data.json |