jq solved JSON on the command line, but so much of our configuration lives in YAML - CI pipelines, container compose files, and, in the Drupal world, exported config. yq brings the same idea to YAML (and JSON and XML): a portable, jq-style processor that reads, queries, and - crucially - edits these files in place, preserving comments and formatting where it can.
Query and Edit YAML
Reading is jq-familiar; the ability to write values back is what sets it apart:
# Read a nested value
yq '.services.web.image' docker-compose.yml
# Update a value in place
yq -i '.langcode = "en"' config.yml
# Convert YAML to JSON
yq -o=json '.' config.yml
Scriptable Config Surgery
Because it edits in place and speaks multiple formats, yq is a natural fit in scripts and CI - flip a flag in a config, bump an image tag, or convert a file's format without hand-editing. It's the tool you reach for when a pipeline needs to touch a YAML file programmatically.
Rough Edges and Limitations
- Two tools share the name. This is the Go yq; a Python project uses the same command, so match docs to the one you installed.
- Comment preservation isn't perfect. Most edits keep formatting, but complex rewrites can shuffle it.
- Same learning curve as jq. The power comes with the same syntax to learn.
For anyone whose day includes YAML - and in modern dev that's everyone - yq turns config files into something you can script against.
Internal link suggestion: link "the same idea to YAML" to the jq post, its direct inspiration and JSON counterpart.