Skip to main content
kitlocal.dev

jq Cheatsheet

Runs locally

100% processed in your browser. Inputs and outputs never leave your device.

jq JSON processor filters, pipes, object construction, arrays, select, map, group_by, reduce, and CLI flags verified against jq 1.8.

How it works

Every jq filter transforms an input JSON stream into zero or more output JSON values. Dot (`.`) is the identity filter; pipes (`|`) pass each output of the left filter into the right filter, and `.[]` explodes an array or object into a stream of items so you can filter, map and re-wrap them with `[...]`.

Survival kit

The few commands to learn first.

40 commands

Keyboard shortcuts/Focus searchJKMove selectionCCopy selectedFBookmark selectedEscClear search

Inspect & format JSON

Start with `.` to validate and pretty-print JSON, or `-r`/`-c` to adapt formatting for downstream tools.

Official docs: Invoking jq
  • Essential

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    When to use it

    Quickly format minified API responses or confirm JSON syntax from the terminal.

    Breakdown

    .
    identity filter: passes the whole JSON value unchanged

    Example

    echo '{"b":2,"a":1}' | jq -c .

    Result

    {"b":2,"a":1}

    Also works

    • jq -S . <file.json> (sort object keys alphabetically)

    See also

Access fields & arrays

Chain property names with `.a.b`, index arrays with `.[0]`, and append `?` to skip missing/null errors.

Official docs: Basic filters

Filter & transform

Combine `select(cond)` to drop items and `map(...)` or `[...]` to transform the remaining ones.

Official docs: Builtin operators & functions

Sort, group & aggregate

Group records by a key, deduplicate, compute totals, or flatten nested arrays.

Official docs: Sorting and grouping

CLI variables, CSV & shell interop

Pass shell parameters safely with `--arg` / `--argjson` and export tables directly with `@csv` or `@tsv`.

Official docs: Format strings and escaping

Try it in a KitLocal tool

Glossary
Filter
An expression in jq that takes a JSON value and outputs zero or more values.
Stream
Multiple values produced by `.[]` or `,` before wrapping back into an array with `[...]`.
Raw output (-r)
Outputs strings without JSON surrounding quotes — essential when feeding bash or grep.
Compact (-c)
Prints each JSON object on a single line (NDJSON / JSON Lines).

Checked on Nov 15, 2026 · Checked against jq 1.8

Sources: jq Manual (jqlang.org)

Replace anything in angle brackets with your own values. Commands come from the official documentation, and examples were run on the version shown.