yq is a lightweight, portable command-line processor for YAML, JSON, XML, INI, properties, CSV and TSV. It uses jq-like syntax so people already familiar with jq can query and edit structured files. It is written in Go, so you can download a dependency-free binary for your platform, or install it through package managers, Docker or Podman.
Install & use
Install
brew install yq
Usage
yq '.a.b[0].c' file.yaml
mikefarah/yq is a third-party open-source project, listed here from public GitHub data. ImuTechz did not write it and has not reviewed or security-audited its code. Read the source and its permissions before you install or run it.
Features
Read and update values with jq-like expressions
Edit YAML files in place with the -i flag
Set values from environment variables with strenv()
Merge multiple files, including via globs
Convert between formats such as JSON, YAML and XML
Available as a dependency-free Go binary, via package managers, Docker and Podman
Best for
Querying and editing YAML config files from the shell
Converting between YAML, JSON, XML and other formats
Scripted bulk updates and merges of structured files
CI or container workflows using the Docker image
Pros
Written in Go, so a dependency-free binary is available for each platform
Supports many formats beyond YAML, including JSON, XML, INI, properties, CSV and TSV
Uses familiar jq-like syntax for common operations
Installable through Homebrew, snap, Docker and Podman as well as direct download
Cons
Does not yet support everything jq does
The snap package uses strict confinement, so it cannot directly access root files
The container image no longer runs as root by default