yq is a lightweight and portable command-line YAML processor
yq is a lightweight and portable command-line YAML processor. yq uses jq like syntax but works with yaml files as well as json. It doesn't yet support everything jq does - but it does support the most common operations and functions, and more is being added continuously.
yq is written in go - so you can download a dependency free binary for your platform and you are good to go! If you prefer there are a variety of package managers that can be used as well as docker, all listed below.
Version 4 of yq is a major upgrade that now fully supports complex expressions for powerful filtering, slicing and dicing yaml documents. This new version uses syntax very similar to jq and works very similarly, so if you've used jq before this should be a low learning curve - however it is quite different from previous versions of yq. Take a look at the upgrade guide for help.
Support for v3 will cease August 2021, until then, critical bug and security fixes will still get applied if required.
How it works
yq works by runningyaml nodes against a filter expression. The filter expression is made of of operators that pipe into each other. yaml nodes are piped through operators, operators may either return a different set of nodes (e.g. children) or modify the nodes (e.g. update values). See the operator documentation for more details and examples.