Skip to content
Latchkey

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

FunctionWhat it does
ascii_downcaseLowercase ASCII letters
ascii_upcaseUppercase ASCII letters
ltrimstr / rtrimstrStrip 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

Run this faster and cheaper on Latchkey managed runners. Start free →