Analyze view
The Analyze view builds a jq query from steps you pick, such as Filter, Sort, and Group, so you can transform a document without writing the whole query yourself. Each step works on the result of the one before it. The view shows the jq expression it produces, which you can copy and reuse.
The Analyze view is available for JSON files. Select Analyze in the view switcher. The pipeline always runs on the whole document, from its root, and most steps expect the root to be an array. To query an array inside the document, write a jq query instead.
Build a pipeline
Section titled “Build a pipeline”-
Select Add step (the plus button) and choose a step type.
-
Fill in the step’s fields in the config panel, for example the filter expression
.status == "pending". -
Add more steps the same way. The buttons on each step are Move up and Move down, Disable step to turn the step off without removing it, and Remove. Hover over a button to see its name.
-
Select Run.
The Output Preview shows the result as indented JSON. Above it, jq: shows the expression that ran, with the number of results and the time taken. The output updates only when you select Run; editing a step does not run it again.
To see the result partway through, select Preview up to this step on a step. Clear all removes every step.
If a step is invalid, the error appears above the output, for example jq parse error: ….
Step types
Section titled “Step types”| Step | Fields | Does |
|---|---|---|
| Filter | Expression, for example .active == true |
Keeps the elements for which the expression is true |
| Map | Expression, for example {name: .name, id: .id} |
Replaces each element with the expression’s result |
| Sort | Key, Descending | Sorts the elements by a key |
| Group | Key | Groups elements with the same key value into arrays |
| Select Fields | Fields (comma-separated), for example .name, .id |
Keeps only the listed fields of each element |
| Flatten | none | Merges nested arrays into one array |
| Unique | Key (optional) | Removes duplicate elements, or elements with a duplicate key value |
| Limit | Count | Keeps the first elements |
| Custom jq | Expression | Runs any jq expression |
For the jq language, see Query syntax.
Save and load pipelines
Section titled “Save and load pipelines”To reuse a pipeline, select Save, give it a name and an optional description, and select Save in the dialog. Saving under a name that is already used replaces that pipeline.
To load one, select Templates (the button next to Add step). The Saved Pipelines list shows each pipeline with its number of steps; click one to replace the current steps with it. The list is empty until you save a pipeline.
The steps of an unsaved pipeline are lost when you close the tab.
Copy as jq
Section titled “Copy as jq”Select Copy jq to copy the expression of the last run, for example:
map(select(.status == "pending")) | sort_by(.id) | [limit(10; .[])]Paste it into the jq playground, the jdig query prompt, or the jq command-line tool. Copy jq copies what last ran: after Preview up to this step, it copies only the steps up to that one, and after you change steps, select Run again before copying.
Large documents
Section titled “Large documents”The pipeline loads the whole document into memory, so a very large document fails with “Subtree too large to query in memory”. For such a file, use SQL, or the jq playground on an array inside the document. See Limits.