メインコンテンツへスキップ
kitlocal.dev

jqチートシート

ローカルで実行

100% ブラウザ内で処理されます。入力や出力が端末の外に送信されることはありません。

jq 1.8 で動作確認済みの jq JSON プロセッサ用フィルター、パイプ、オブジェクト構築、配列、select、map、group_by、reduce、CLI フラグ。

動作の仕組み

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

サバイバルキット

最初に覚えるべき最小限のコマンド。

40 件のコマンド

キーボードショートカット/検索にフォーカスJK選択を移動C選択項目をコピーF選択項目をブックマークEsc検索をクリア

Inspect & format JSON

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

公式ドキュメント: Invoking jq
  • 基本

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    使いどころ

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

    コマンドの内訳

    .
    identity filter: passes the whole JSON value unchanged

    実例

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

    実行結果

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

    他の方法

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

    関連項目

Access fields & arrays

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

公式ドキュメント: Basic filters

Filter & transform

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

公式ドキュメント: Builtin operators & functions

Sort, group & aggregate

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

公式ドキュメント: Sorting and grouping

CLI variables, CSV & shell interop

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

公式ドキュメント: Format strings and escaping

KitLocalツールで試す

用語集
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).

2026/11/15 に検証済み · jq 1.8 で検証済み

出典: jq Manual (jqlang.org)

山括弧内の内容は実際の値に置き換えてください。コマンドは公式ドキュメントに基づいており、実例は記載されたバージョンで実行確認されています。