# jq

> Command-line JSON processor for slicing, filtering, mapping and transforming structured data

Stars: 36.0k · Language: C · License: MIT · Categories: Data

- Repository: https://github.com/jqlang/jq
- Website: https://jqlang.org
- Page: https://www.trmn.sh/tools/jq
- Demo video: https://media.trmn.sh/demos/9c9a4ef2ecdf1e4d1a8d78b8e66ba3e630c9266506e7d6a1243b148d8d32eaf7.mp4

## Install

- Docker: `docker run --rm -i ghcr.io/jqlang/jq:latest`
- Source: `git submodule update --init && autoreconf -i && ./configure --with-oniguruma=builtin && make -j8 && sudo make install`

## Overview

jq is a command-line JSON processor that provides sed/awk/grep-like functionality for JSON data. Written in portable C with zero runtime dependencies, it enables users to slice, filter, map, and transform structured JSON data through a domain-specific query language.

The tool operates as a filter, taking JSON input and producing JSON output based on specified expressions. Users can extract specific fields, transform data structures, perform calculations, and apply complex queries to JSON documents. jq supports advanced operations including array manipulation, object construction, conditional logic, and mathematical operations on JSON data.

Developers, system administrators, and data engineers commonly use jq for processing API responses, configuration files, log analysis, and data pipeline operations. The tool integrates well into shell scripts and command pipelines, making it particularly valuable for automation tasks that involve JSON data manipulation. jq can be built as a statically linked binary and supports cross-compilation for various platforms.

### Installation

```bash
# via Docker
docker run --rm -i ghcr.io/jqlang/jq:latest
```

```bash
# via Source
git submodule update --init && autoreconf -i && ./configure --with-oniguruma=builtin && make -j8 && sudo make install
```

## Alternatives

- [jo](https://www.trmn.sh/tools/jo.md): Command-line utility to create JSON objects and arrays from shell arguments and piped input (C, 4.9k stars)
- [pandoc](https://www.trmn.sh/tools/pandoc.md): Haskell library and command-line tool that converts documents between dozens of markup formats, including Markdown, LaTeX, HTML, docx, EPUB and PDF. (Haskell, 46.8k stars)
- [fx](https://www.trmn.sh/tools/fx.md): Terminal-based JSON processor and viewer for querying, filtering, and manipulating JSON data interactively. (Go, 20.7k stars)
- [yq](https://www.trmn.sh/tools/yq.md): Command-line YAML, JSON, XML, and CSV processor with jq-like syntax for querying and transforming structured data (Go, 16.2k stars)
- [gron](https://www.trmn.sh/tools/gron.md): Transforms JSON into discrete assignments to make it greppable and enable exploration of complex JSON structures (Go, 14.5k stars)

## Guides

- [Benchmark shell commands with hyperfine](https://www.trmn.sh/guides/benchmark-commands-hyperfine): Time shell commands with hyperfine: warmup runs, cache-clearing with --prepare, side-by-side comparisons, parameter scans and Markdown or JSON export.
- [Filter JSON logs and count errors with jq](https://www.trmn.sh/guides/jq-json-log-workflow): Use jq to select errors from JSON Lines logs, keep useful fields, and count failures by service.
- [Best JSON CLI Tools](https://www.trmn.sh/best/json-cli-tools): Compare jq, yq, gojq, fx, dasel, gron and qo for querying, filtering and transforming JSON (and YAML) from the command line.

---

Canonical: https://www.trmn.sh/tools/jq
