Command-line processor for YAML, JSON, XML, and other data formats with jq-like syntax
yq is a command-line data processor that handles YAML, JSON, XML, INI, CSV, TSV, and other structured data formats. It uses jq-compatible syntax but extends beyond JSON to work with multiple file types, making it particularly useful for configuration file manipulation and data transformation tasks.
The tool supports in-place file editing, multi-document YAML processing, and format conversion between different data types. Key operations include reading values with path expressions like .a.b[0].c, updating files with environment variable substitution using strenv(), and merging multiple files using load functions. It can convert between formats seamlessly, such as transforming JSON to YAML or XML to JSON.
yq maintains YAML formatting and comments during updates, handles front matter blocks for static site generators, and provides advanced features like date/time manipulation, base64 encoding/decoding, and complex array operations. The tool is written in Go and distributed as a dependency-free binary, with support for Docker containers, GitHub Actions, and various package managers across platforms.
# via Homebrew
brew install yq
# via Go
go install github.com/mikefarah/yq/v4@latest
# via Snap
snap install yq