jq ascii_downcase : Lowercase a String
jq ascii_downcase lowercases the ASCII letters of a string; ascii_upcase uppercases them.
Normalizing case is common before comparing API labels or branch names, where casing is inconsistent across sources in CI.
What it does
ascii_downcase converts A-Z to a-z and leaves other characters untouched; ascii_upcase does the reverse. They operate only on ASCII letters, so accented characters pass through unchanged.
Common usage
Terminal
# normalize a label before comparing
jq '.[] | select((.name | ascii_downcase) == "bug")' labels.json
# lowercase a branch ref for a tag
jq -r '.ref | ascii_downcase' event.json
# uppercase an environment name
echo '"prod"' | jq 'ascii_upcase'Functions
| Function | What it does |
|---|---|
| ascii_downcase | Lowercase ASCII letters |
| ascii_upcase | Uppercase ASCII letters |
| ltrimstr / rtrimstr | Strip a known prefix/suffix |
| gsub("re";"x") | Replace by regex (broader edits) |
Common errors in CI
"jq: error: ascii_downcase input must be a string" (or "number (5) cannot be ...") means the field is not a string; coerce with tostring first. If the value is null, guard it with (.name // "") before downcasing so the filter does not fail mid-stream.
Related guides
jq split, join, ltrimstr : Cut and Trim Stringsjq split(sep) breaks a string into an array, join(sep) merges one, and ltrimstr/rtrimstr strip a known prefix…
jq gsub and sub : Regex Replace in Stringsjq gsub replaces all regex matches and sub replaces the first. Reference for cleaning version strings and ref…
jq test() : Match a String Against a Regexjq test(re) returns true when a string matches a regex. Reference for filtering gh api items by pattern in CI…
jq walk, paths and getpath : Deep JSON Editsjq walk(f) transforms every value depth-first, while paths and getpath address deep fields. Reference for cle…