Convert JSON to YAML

Pretty-print JSON as YAML

cat config.json | yq -P '.'

tool
yq15 commands
tags
yq

More yq commands

  • yq '.items[] | select(.status.phase == "Running")' pods.yaml

    Select only Running pods from a list

  • yq -i '(.spec.template.spec.containers[] | select(.name == "app") | .image) = "myapp:v2.0.0"' deployment.yaml

    Targeted image update for a named container

  • yq '.metadata.name' manifests/*.yaml

    Extract metadata.name from all YAML files in a directory

  • yq '.spec.replicas' deployment.yaml

    Extract a value from a YAML file

  • yq -i '.spec.replicas = 3' deployment.yaml

    In-place update of a YAML field

all 15 yq commands