Aller au contenu principal
kitlocal.dev

Aide-mémoire jq

Exécution locale

Traitement à 100 % dans votre navigateur. Vos entrées et sorties ne quittent jamais votre appareil.

Filtres du processeur JSON jq, pipes, construction d'objets, tableaux, select, map, group_by, reduce et options CLI vérifiés sur jq 1.8.

Comment ça fonctionne

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 `[...]`.

Kit de survie

Les quelques commandes à apprendre en premier.

40 commandes

Raccourcis clavier/Cibler la rechercheJKDéplacer la sélectionCCopier la sélectionFMettre la sélection en favoriEscEffacer la recherche

Inspect & format JSON

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

Documentation officielle : Invoking jq
  • Essentiel

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    Quand l'utiliser

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

    Décomposition

    .
    identity filter: passes the whole JSON value unchanged

    Exemple

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

    Résultat

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

    Fonctionne aussi

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

    Voir aussi

Access fields & arrays

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

Documentation officielle : Basic filters

Filter & transform

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

Documentation officielle : Builtin operators & functions

Sort, group & aggregate

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

Documentation officielle : Sorting and grouping

CLI variables, CSV & shell interop

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

Documentation officielle : Format strings and escaping

Essayer dans un outil KitLocal

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

Vérifié le 15 nov. 2026 · Vérifié avec la version jq 1.8

Sources: jq Manual (jqlang.org)

Remplacez les éléments entre chevrons par vos propres valeurs. Les commandes proviennent de la documentation officielle et les exemples ont été exécutés sur la version indiquée.