Zum Hauptinhalt springen
kitlocal.dev

jq-Cheatsheet

Läuft lokal

Zu 100 % in deinem Browser verarbeitet. Eingaben und Ausgaben verlassen niemals dein Gerät.

jq-JSON-Filter, Pipes, Objekterstellung, Arrays, select, map, group_by, reduce und CLI-Flags, verifiziert gegen jq 1.8.

Funktionsweise

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

Die wichtigsten Befehle für den Einstieg.

40 Befehle

Tastenkürzel/Suche fokussierenJKAuswahl bewegenCAuswahl kopierenFAuswahl als Lesezeichen speichernEscSuche leeren

Inspect & format JSON

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

Offizielle Dokumentation: Invoking jq
  • Grundlagen

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    Wann verwenden

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

    Aufbau

    .
    identity filter: passes the whole JSON value unchanged

    Beispiel

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

    Ergebnis

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

    Alternativen

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

    Siehe auch

Access fields & arrays

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

Offizielle Dokumentation: Basic filters

Filter & transform

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

Offizielle Dokumentation: Builtin operators & functions

Sort, group & aggregate

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

Offizielle Dokumentation: Sorting and grouping

CLI variables, CSV & shell interop

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

Offizielle Dokumentation: Format strings and escaping

In einem KitLocal-Tool ausprobieren

Glossar
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).

Geprüft am 15.11.2026 · Geprüft mit jq 1.8

Quellen: jq Manual (jqlang.org)

Ersetze Werte in spitzen Klammern durch deine eigenen Angaben. Befehle stammen aus der offiziellen Dokumentation, und Beispiele wurden mit der angegebenen Version ausgeführt.