Command-line YAML/JSON/XML processor (like jq but for YAML).
low risk
yq processes YAML, JSON, XML, and TOML files with a jq-compatible syntax. Invaluable for editing Kubernetes manifests, Helm values files, and CI config files without breaking structure. The -i flag edits files in-place.
| Flag | Meaning |
|---|---|
-i --inplace | Edit file in-place |
-r --raw | Output raw strings |
-o --output-format | Output format: yaml, json, props |
yq '.spec.replicas' deployment.yamlRead replica count from a manifest · explain & risk-check →yq -i '.spec.replicas = 3' deployment.yamlUpdate replica count in-place · explain & risk-check →yq -o json deployment.yaml | jq '.spec'Convert YAML to JSON for jq processing · explain & risk-check →yq eval-all '. as $item ireduce ({}; . * $item)' base.yaml override.yamlDeep merge two YAML files · explain & risk-check →Use yq to patch image tags in manifests during CI: `yq -i '.spec.template.spec.containers[0].image = "app:v1.2.3"' deploy.yaml` — cleaner than sed on YAML.
Reference text is hand-written and may be incomplete — check man yq for your version. Test destructive commands on a non-production system first.