Chuyển tới nội dung chính
kitlocal.dev

Bảng tra cứu nhanh jq

Chạy cục bộ

Xử lý 100% ngay trong trình duyệt. Dữ liệu đầu vào và kết quả không rời khỏi thiết bị.

Bộ lọc JSON với jq: truy vấn trường, pipe, map, select, dựng object/mảng, group_by, reduce và các cờ dòng lệnh trên jq 1.8.

Cách hoạt động

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

Bộ lệnh sống còn

Vài lệnh nên học trước tiên.

40 lệnh

Phím tắt/Tìm kiếmJKDi chuyển mục chọnCSao chép lệnh đang chọnFĐánh dấu mục đang chọnEscXoá tìm kiếm

Inspect & format JSON

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

Tài liệu chính thức: Invoking jq
  • Cơ bản

    Validate and pretty-print JSON with syntax highlighting.

    jq . <file.json>

    Khi nào dùng

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

    Giải thích từng phần

    .
    identity filter: passes the whole JSON value unchanged

    Ví dụ

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

    Kết quả

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

    Cách khác

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

    Xem thêm

Access fields & arrays

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

Tài liệu chính thức: Basic filters

Filter & transform

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

Tài liệu chính thức: Builtin operators & functions

Sort, group & aggregate

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

Tài liệu chính thức: Sorting and grouping

CLI variables, CSV & shell interop

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

Tài liệu chính thức: Format strings and escaping

Dùng thử trong công cụ KitLocal

Thuật ngữ
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).

Kiểm tra ngày 15 thg 11, 2026 · Đối chiếu với jq 1.8

Nguồn: jq Manual (jqlang.org)

Hãy thay phần trong dấu ngoặc nhọn bằng giá trị của bạn. Lệnh lấy từ tài liệu chính thức, ví dụ đã được chạy thử trên phiên bản được ghi.