Skip to content

jq Filter Builder

Quick Answer

jq filters are the fastest way to pull fields out of a JSON API response in a bash script, but the syntax is easy to get subtly wrong — a missing -r leaves quotes on your value, a forgotten // turns a missing key into the literal null, and a select() with the wrong quoting matches nothing. This builder removes the guesswork. Paste a real response (or load a sample), then click through the actual structure to build the path; the tool shows the jq filter and the full curl … | jq command, and evaluates the filter against your JSON live so you can see exactly what comes out before you run it. It covers the patterns people actually script: nested field access, array indexing, iterating an array with a select() filter and projecting one field, defaults, and raw output. No data leaves your browser — parsing and evaluation happen client-side.

How to use the jq Filter Builder

  1. 1Paste a JSON response into the box on the left, or load one of the sample responses to start.
  2. 2Click any field in the structure view to set the jq path — the filter and preview update as you click.
  3. 3For array fields, tick 'iterate each element', then optionally add a select() filter and choose one field to output.
  4. 4Toggle raw output (-r) when the value is going into a shell variable, and add a // default for fields that may be missing.
  5. 5Copy the jq filter into your script, or copy the whole curl … | jq command to test it against the endpoint.

Frequently Asked Questions

faq — tool

Does this run jq or send my JSON to a server?

No. The tool parses and evaluates your JSON entirely in the browser with JavaScript — nothing is uploaded and no jq binary is called remotely. The live preview mirrors what jq would output for the supported patterns, so you can paste a real (even sensitive) response safely and still see the result before running the command anywhere.

faq — tool

Why does my extracted value come out wrapped in quotes?

That is jq printing a JSON string, quotes included. Turn on raw output (-r) and the quotes disappear. This matters the moment the value goes into a shell variable, a filename, or a comparison: "web-01" with the quotes will not equal web-01, so almost any value headed into bash wants -r.

faq — tool

The filter looks right but the preview is empty — why?

Three common reasons: a select() filter matched no elements (jq would also output nothing), the path points at a key that does not exist in this response, or you used // empty as a default, which deliberately produces no output for a missing value. The note under the preview tells you which case you hit.

faq — tool

Does this support the entire jq language?

No — it builds the common extraction patterns that cover most API scripting: field and nested access, array indexing, iteration with select() and projection, // defaults, and -r. Advanced jq (reduce, string interpolation, arithmetic, if/then/else, custom functions) is out of scope; the jq manual is the reference for those.

PAID RESOURCE — $9

The Production Bash Toolkit

An operational script system + a 31-function shared library + a 52-page field guide. The production layer the free snippets don't cover.

Get the Toolkit →
curl -O bashlib-starter.sh

Get the bashlib starter

Ten functions I source into every script on my own boxes — strict-mode setup, an ERR trap that names the failing line, lock and timeout wrappers, and cleanup that runs on every exit path. One email, no sequence.

Related Snippets