yq
yq is a portable command-line YAML, JSON, XML, CSV, TOML, HCL and properties processor
A command-line tool for reading, editing, and converting config files, YAML, JSON, XML, TOML, CSV, and more, with simple one-line commands using jq-style path syntax.
yq is a small command-line tool for reading and editing structured configuration files. It handles YAML, JSON, XML, CSV, TSV, TOML, HCL, INI, and Java-style properties files. The pitch is that you can pull a value out of a config file, change a setting, or convert between formats with one terminal command instead of writing a script.
Its syntax is borrowed from jq, a popular tool for working with JSON, so a path like .a.b[0].c reads the value of c in the first item of list b inside object a. The README shows the common patterns: reading a value, updating a file in place with the -i flag, substituting environment variables into the file, merging two or more files into one, finding an item in an array by a field and updating it, and converting between formats — for example dumping JSON as pretty-printed YAML, or XML as YAML. There is also a GitHub Action wrapper so you can run the same commands inside a continuous-integration workflow.
You would reach for yq when you are working with DevOps configuration — Kubernetes manifests, CI pipelines, Ansible inventories, Helm values, application config files — and want a quick, scriptable way to inspect or change them without opening an editor. It is written in Go and ships as a single dependency-free binary, which means you can drop it onto any machine and run it without installing a runtime. The README lists many ways to install it: direct binary download, Homebrew on macOS and Linux, snap, Docker and Podman images, a Nix package, an Arch package, Chocolatey on Windows, and go install. The full README is longer than what was provided.
Where it fits
- Extract or update a value in a Kubernetes YAML manifest without opening an editor.
- Convert a JSON config file to pretty-printed YAML (or vice versa) in one terminal command.
- Substitute environment variables into a config file as part of a CI/CD pipeline script.
- Merge two or more YAML files together and search or filter the combined result.