Utilities
Filter and reshape JSON with jq
Turn one JSON document into the exact records the next node needs.
overview
What jq does
Connect a JSON file, enter a jq filter, and the node writes jq's stdout to a workflow output file. The filter is positional, so expressions such as .items[] or map(select(.enabled)) work as they do in the jq CLI.
-r writes strings without JSON quotes, -c emits one compact value per line, -s collects all inputs into an array, and -R reads lines as strings. Leave modes disconnected unless the filter needs them.
The wrapper writes through a temporary file and only publishes the result after jq exits successfully. A syntax error or malformed input fails the node instead of leaving a partial artifact.
source github.com/jqlang/jq
use cases
Where jq fits
Select fields
Project large records into a smaller object before passing them downstream.
Filter arrays
Keep records that match a condition and discard the rest.
Convert JSON to text
Use -r when the next node expects newline-delimited strings rather than JSON strings.
reference
jq inputs and flags
| Name | Type | Flag | Description |
|---|---|---|---|
| filter | STRING | --filter | jq expression to evaluate. |
| input | FILE | --input | JSON input file. |
| raw-output | BOOLEAN | --raw-output | Write strings without JSON quoting. |
| compact | BOOLEAN | --compact | Write compact JSON. |
Showing key inputs. jq exposes 6 inputs in total.
Full flag reference (6 inputs)
| Name | Type | Flag | Description |
|---|---|---|---|
| raw-output | BOOLEAN | --raw-output | Write strings without JSON quoting |
| compact | BOOLEAN | --compact | Write compact JSON |
| slurp | BOOLEAN | --slurp | Read all input values into one array |
| raw-input | BOOLEAN | --raw-input | Read each input line as a string |
| filter | STRING | --filter | jq filter expression |
| input | FILE | --input | JSON input file |
example
Run jq
jq -c '.items[] | {name, doubled: (.n * 2)}' input.json{"name":"alpha","doubled":4}{"name":"beta","doubled":6}guidance
Choosing jq
Use jq when the input is JSON and the transformation fits a jq expression. Use yq for YAML, XML, or TOML, and Miller for record-oriented CSV work.
yq
Queries YAML, XML, TOML, and JSON with a jq-like expression language.
miller
Transforms CSV and other record-oriented formats with named verbs.
duckdb
Runs SQL over larger JSON, CSV, and Parquet datasets.
faq
jq 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 jq yourself
A two-record JSON fixture feeds jq, which calculates a doubled field and writes compact JSON objects.
Facts on this page come from the live Trickest tool library.