yq is a portable command-line YAML, JSON, XML, CSV, TOML and properties processor
Go to file
2025-10-12 14:31:03 +11:00
.gitbook/assets GitBook: [#206] deep update example 2021-10-30 03:14:39 +00:00
commands Fixing docs 2024-03-24 11:09:39 +11:00
operators v4.48.1 2025-10-12 14:31:03 +11:00
usage v4.48.1 2025-10-12 14:31:03 +11:00
how-it-works.md v4.35.2 2023-09-26 14:50:18 +10:00
README.md Updating readme 2025-07-23 16:15:42 +10:00
SUMMARY.md v4.48.1 2025-10-12 14:31:03 +11:00
upgrading-from-v3.md Fixed doc typos (#1457) 2022-12-05 16:49:31 +11:00

yq

aa lightweight and portable command-line YAML, JSON, INI and XML processor. yq uses jq like syntax but works with yaml files as well as json, xml, ini, properties, csv and tsv. 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 and Podman, all listed below.

Quick Usage Guide

Read a value:

yq '.a.b[0].c' file.yaml

Pipe from STDIN:

yq '.a.b[0].c' < file.yaml

Update a yaml file, in place

yq -i '.a.b[0].c = "cool"' file.yaml

Update using environment variables

NAME=mike yq -i '.a.b[0].c = strenv(NAME)' file.yaml

Merge multiple files

# merge two files
yq -n 'load("file1.yaml") * load("file2.yaml")'

# merge using globs:
# note the use of `ea` to evaluate all the files at once
# instead of in sequence
yq ea '. as $item ireduce ({}; . * $item )' path/to/*.yml

Multiple updates to a yaml file

yq -i '
  .a.b[0].c = "cool" |
  .x.y.z = "foobar" |
  .person.name = strenv(NAME)
' file.yaml

Find and update an item in an array:

yq '(.[] | select(.name == "foo") | .address) = "12 cat st"'

Convert JSON to YAML

yq -Poy sample.json

See recipes for more examples and the documentation for more information.

Take a look at the discussions for common questions, and cool ideas

Install

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

Known Issues / Missing Features

See tips and tricks for more common problems and solutions.