Three tools, one shape
Each lets you query and transform structured data with a small expression language:
jq— JSON. The original, most widely deployed.yq— YAML, with a jq-compatible syntax. By Mike Farah's go-yq (different from the older python-yq).dasel— JSON, YAML, TOML, XML, CSV in one tool with a single jq-like syntax. Newest, broadest format support.
jq — already covered
See textproc.lesson7. The jq filter language is the lingua franca; every other tool below either copies it or improves on it.
yq — YAML the same way
brew install yq
yq '.metadata.name' deployment.yaml
yq '.spec.replicas = 5' -i deployment.yaml # in-place edit
yq -o=json '.' config.yaml | jq # convert to JSONdasel — universal
brew install dasel
dasel -f config.yaml '.database.host'
dasel -f Cargo.toml '.package.version'
dasel -f data.csv '.[0].name'
dasel -f doc.xml '.root.item.name'One tool to query any structured file format you'll meet daily.
When to reach for which
- JSON only →
jq(most ubiquitous, most docs). - YAML primarily →
yq(matches jq syntax exactly, in-place edit). - Mixed formats in one script →
dasel.