# yq
> A portable command-line YAML, JSON, XML, CSV and properties processor

## 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

## When to Use
- Editing Kubernetes manifests programmatically
- Extracting values from CI/CD config files
- Converting between YAML and JSON
- Batch-updating YAML configuration files

## When NOT to Use
- Working exclusively with JSON (use jq instead)
- Need complex programming logic (use Python/Ruby)
- 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

## Installation
- **homebrew**: `brew install yq`
- **go**: `go install github.com/mikefarah/yq/v4@latest`
- **snap**: `sudo snap install yq`

## Related Tools
- [jq](/tools/jq) (complementary): jq for JSON, yq for YAML - similar syntax

---
Source: https://littlescripts.sh/tools/yq
