Primary Use Cases
1. YAML to JSON Conversion
# Convert entire YAML file to JSON
yq eval '.' config.yaml --output-format=json
# Extract specific sections
yq eval '.database.connections' config.yaml --output-format=json2. YAML Querying and Extraction
# Get specific values
yq eval '.server.port' config.yaml
# Filter arrays
yq eval '.users[] | select(.active == true)' users.yaml
# Get all keys at a level
yq eval 'keys' config.yaml3. YAML Manipulation
# Update values
yq eval '.server.port = 8080' -i config.yaml
# Add new fields
yq eval '.newField = "newValue"' -i config.yaml
# Merge YAML files
yq eval-all 'select(fileIndex == 0) * select(fileIndex == 1)' file1.yaml file2.yaml4. Format Conversion
# YAML to JSON
yq eval '.' file.yaml --output-format=json
# YAML to XML
yq eval '.' file.yaml --output-format=xml
# YAML to Properties
yq eval '.' file.yaml --output-format=props
# YAML to CSV (for arrays)
yq eval '.' file.yaml --output-format=csv