Utilities
Query and convert structured files with yq
Use one expression language across YAML, JSON, XML, TOML, and properties.
overview
What yq does
Connect a structured file and set the yq expression to evaluate. The node writes the selected value or transformed document to a workflow output file, using the same expression syntax as Mike Farah's yq v4.
-p selects the input format when filename detection is not enough. -o controls the result format, so a YAML input can become JSON without a separate conversion step. -n evaluates an expression without reading an input document.
The wrapper stages output in the destination directory and moves it into place only after yq succeeds. Invalid syntax and parse errors fail the node instead of publishing partial content.
source github.com/mikefarah/yq
use cases
Where yq fits
Read deployment settings
Select a nested value or object from a YAML configuration file.
Convert YAML to JSON
Set -o to json and return the selected document as JSON.
Generate a document
Enable -n to build YAML or JSON from an expression without an input file.
reference
yq inputs and flags
| Name | Type | Flag | Description |
|---|---|---|---|
| expression | STRING | --expression | yq expression to evaluate. |
| input | FILE | --input | YAML, JSON, XML, TOML, or properties file. |
| output-format | STRING | --output-format | Output format such as yaml or json. |
| input-format | STRING | --input-format | Explicit input format when needed. |
Showing key inputs. yq exposes 5 inputs in total.
Full flag reference (5 inputs)
| Name | Type | Flag | Description |
|---|---|---|---|
| input-format | STRING | --input-format | Input format such as yaml, json, xml, or toml |
| output-format | STRING | --output-format | Output format such as yaml, json, xml, or toml |
| null-input | BOOLEAN | --null-input | Evaluate without an input file |
| expression | STRING | --expression | yq expression to evaluate |
| input | FILE | --input | YAML, JSON, XML, TOML, or properties input file |
example
Run yq
yq -o json '.service' input.yaml{ "name": "alpha", "enabled": true}guidance
Choosing yq
Use yq for YAML, XML, TOML, properties, or mixed-format conversion. Use jq when every input is JSON, and Miller when tabular records are the main unit.
jq
The focused choice for JSON filtering and transformation.
miller
Better suited to CSV, TSV, and streams of records.
duckdb
Uses SQL for larger datasets and multi-file queries.
faq
yq questions
related
More Utilities tools
browser-fetch
Headless Chromium render: requested URL, final URL, status, and title next to the page.
cewl
Spider a URL and return a wordlist for password crackers.
csvkit
SQL on one CSV. The table name is the file stem.
dnsgen
Wordlist and mined-word subdomain permutation.
duckdb
In-process SQL on CSV, JSON, and Parquet. No server.
edge-tts
Microsoft Edge neural speech from text or a script file. No API key.
Run yq yourself
A YAML service object feeds yq with .service and -o json, producing a JSON object for the next node.
Facts on this page come from the live Trickest tool library.