Copy · paste · pipe

jq one-liners you can actually paste.

Ready-to-run jq recipes for the JSON tasks you actually do — filter with select(), reshape with map(), build objects, sort and group arrays, and spit out CSV — each with example input and output so you can see exactly what it does.

15 recipes

Why this exists

You know what you want. You don't remember the jq for it.

jq is unreasonably powerful, but the syntax for "filter this array of objects by a nested field" or "turn this into CSV" never sticks — so you re-derive it, or paste a half-right snippet from a six-year-old answer. jqsnap.pages.dev is the opposite: each recipe is a focused, copy-paste filter for one real task, with sample input and the exact output it produces, so you can confirm it before you run it on your data.

How it works

Find the task, copy the filter, pipe your JSON

  1. Pick a recipe. Browse by task in the full recipe list.
  2. Copy the filter. Every jq command has a one-click copy button.
  3. Pipe your data. cat data.json | jq '...' or curl ... | jq '...' — each recipe shows example input and output.

FAQ

Frequently asked questions

Are these jq recipes free?

Yes. Every recipe on jqsnap.pages.dev is free to read and copy, with no account, paywall, or sign-up. Some outbound links (for example to dev tools or hosting) may be affiliate links, which never change the price you pay.

Do I need jq installed?

Yes — jq is a small standalone binary. Install it with "brew install jq" (macOS), "sudo apt install jq" (Debian/Ubuntu), or "winget install jqlang.jq" (Windows). The install recipe covers every platform.

How do I pipe a curl / API response into jq?

Pipe stdout straight in: "curl -s https://api.example.com/users | jq '.'". jq reads JSON on stdin, applies your filter, and prints the result. Every recipe shows the filter; prefix it with your curl or cat.

How do I pass a shell variable into a jq filter?

Use --arg (string) or --argjson (number/bool/JSON): "jq --arg name \"$USER\" 'select(.owner == $name)'". Never interpolate shell variables directly into the filter string — see the --arg recipe.

I get "jq: error ... Cannot index ... with ..." — why?

Usually you indexed into null or the wrong type (e.g. .a.b where .a is missing). Use the optional operator "?" (".a.b?") or "// empty" to skip missing paths instead of erroring. The access-fields recipe shows the safe forms.

Which jq version do these target?

jq 1.6 and 1.7+. A few newer builtins (like pick, abs, or improved regex) need 1.7 — recipes note when a feature is version-specific. The core filters here work everywhere.