← Back to tools
View AGENTS.md for yq
yq
A portable command-line YAML, JSON, XML, CSV and properties processor
Description
yq is a lightweight and portable command-line YAML, JSON, XML, CSV, and properties processor. It uses jq-like syntax but works on YAML files and other formats. It can also convert between formats.
Install
homebrew
brew install yqgo
go install github.com/mikefarah/yq/v4@latestsnap
sudo snap install yqAI Summary
Like jq but for YAML (and JSON, XML, CSV). Query, filter, and transform YAML files from the command line. Essential for working with Kubernetes manifests, CI configs, and any YAML-heavy workflow.
Capabilities
- + Query and filter YAML documents with jq-like expressions
- + Edit YAML files in-place
- + Convert between YAML, JSON, XML, CSV, and properties
- + Merge multiple YAML documents
- + Handle multi-document YAML files
- + Evaluate expressions on YAML data
Use When
- → Editing Kubernetes manifests programmatically
- → Extracting values from CI/CD config files
- → Converting between YAML and JSON
- → Batch-updating YAML configuration files
Avoid When
- x Working exclusively with JSON (use jq instead)
- x Need complex programming logic (use Python/Ruby)
- x Document is not valid YAML
Usage Patterns
Extract a field from YAML
yq '.metadata.name' deployment.yaml Extracts the name field from Kubernetes YAML
Convert YAML to JSON
yq -o=json '.' config.yaml Converts a YAML file to JSON format
Update a value in-place
yq -i '.image.tag = "v2.0"' values.yaml Modifies a field directly in the file
Input / Output
stdin: YAML, JSON, XML, or CSV data
stdout: Transformed data in the specified format
Exit codes:
0 Success 1 Error Typical Pipelines
yq -o=json '.' config.yaml | jq '.settings' kubectl get deploy -o yaml | yq '.items[].metadata.name'