y
y
yq
Search…
yq
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.

Quick Usage Guide

Read a value:
1
yq e '.a.b[0].c' file.yaml
Copied!
Pipe from STDIN:
1
cat file.yaml | yq e '.a.b[0].c' -
Copied!
Update a yaml file, inplace
1
yq e -i '.a.b[0].c = "cool"' file.yaml
Copied!
Update using environment variables
1
NAME=mike yq e -i '.a.b[0].c = strenv(NAME)' file.yaml
Copied!
Merge multiple files
1
yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml
Copied!
Multiple updates to a yaml file
1
yq e -i '
2
.a.b[0].c = "cool" |
3
.x.y.z = "foobar" |
4
.person.name = strenv(NAME)
5
' file.yaml
Copied!

Install

See the github page for the various ways you can install and use yq

Known Issues / Missing Features

  • yq attempts to preserve comment positions and whitespace as much as possible, but it does not handle all scenarios (see https://github.com/go-yaml/yaml/tree/v3 for details)
  • Powershell has its own...opinions on quoting yq
See tips and tricks for more common problems and solutions.
Last modified 25d ago