본문으로 바로 가기
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)

꺾쇠괄호 안의 내용을 본인의 값으로 바꾸세요. 명령어는 공식 문서에서 가져왔으며, 예제는 명시된 버전에서 실행되었습니다.