yq is a command-line processor for YAML, JSON, XML, CSV, TOML, HCL, properties, and related formats. It uses jq-like expressions for reading and editing structured files.
Overview
yq is a lightweight Go binary for querying and transforming structured configuration and data files. Its expression style mirrors jq but extends to YAML, INI, XML, properties, CSV, TSV, TOML, and HCL, including Terraform-flavored HCL.
Common tasks include reading paths from files or stdin, in-place updates, merges across multiple inputs, array searches and edits, and format conversion such as JSON to YAML or XML. Multi-document YAML, front matter blocks, comments, tags, anchors, and styling are supported to varying degrees when updating.
Install options include direct binaries for many CPU and OS combinations, Homebrew, snap, Docker or Podman one-shot runs, package managers on Windows and macOS, and importing yqlib from Go code. Shell completion is available for several shells.
It can run in CI via a published GitHub Action. Documentation and recipes cover advanced merges, environment variable substitution, and timezone-aware date operators when timezone data is present in the container image.
Key features
- jq-like queries across many formats
- In-place YAML and JSON updates
- Merge and multi-file reductions
- Format conversion including Terraform HCL
- Multi-document YAML and front matter
- Colorized output and comment preservation
- Go library package for embedding
- Docker and Podman execution
Use cases
- Patching Kubernetes or CI YAML files
- Shell pipelines over JSON or YAML
- Converting config between JSON and YAML
- Terraform and properties file edits