2023-08-03 06:27:09 -07:00
# jq
2012-09-18 23:40:19 +01:00
2023-11-06 15:59:22 +01:00
`jq` is a lightweight and flexible command-line JSON processor akin to `sed` ,`awk` ,`grep` , and friends for JSON data. It's written in portable C and has zero runtime dependencies, allowing you to easily slice, filter, map, and transform structured data.
2015-08-25 08:47:04 -07:00
2023-08-03 06:27:09 -07:00
## Documentation
2012-09-18 23:40:19 +01:00
2025-02-01 11:54:32 +09:00
- **Official Documentation**: [jqlang.org ](https://jqlang.org )
2025-02-17 15:22:05 -08:00
- **Try jq Online**: [play.jqlang.org ](https://play.jqlang.org )
2012-09-18 23:40:19 +01:00
2023-08-03 06:27:09 -07:00
## Installation
2015-02-15 17:57:53 -06:00
2023-08-03 06:27:09 -07:00
### Prebuilt Binaries
2013-05-11 15:15:56 +01:00
2023-08-03 06:27:09 -07:00
Download the latest releases from the [GitHub release page ](https://github.com/jqlang/jq/releases ).
2026-09-15 17:13:25 +08:00
The platform-specific assets are standalone executables, not archives. On macOS and Linux,
rename the downloaded file to `jq` and make it executable with `chmod +x jq` .
2013-06-18 00:28:50 +01:00
2023-08-03 06:27:09 -07:00
### Docker Image
2015-02-15 17:57:53 -06:00
2023-08-03 06:27:09 -07:00
Pull the [jq image ](https://github.com/jqlang/jq/pkgs/container/jq ) to start quickly with Docker.
2015-01-01 16:26:55 -06:00
2024-05-01 07:07:10 +03:00
#### Run with Docker
2025-02-17 15:22:05 -08:00
2024-05-01 07:07:10 +03:00
##### Example: Extracting the version from a `package.json` file
2025-02-17 15:22:05 -08:00
2024-05-01 07:07:10 +03:00
```bash
docker run --rm -i ghcr.io/jqlang/jq:latest < package.json '.version'
```
2025-02-17 15:22:05 -08:00
2024-05-01 07:07:10 +03:00
##### Example: Extracting the version from a `package.json` file with a mounted volume
2025-02-17 15:22:05 -08:00
2024-05-01 07:07:10 +03:00
```bash
2024-05-01 18:56:48 +03:00
docker run --rm -i -v " $PWD : $PWD " -w " $PWD " ghcr.io/jqlang/jq:latest '.version' package.json
2024-05-01 07:07:10 +03:00
```
2023-08-03 06:27:09 -07:00
### Building from source
2015-01-01 16:26:55 -06:00
2023-08-03 06:27:09 -07:00
#### Dependencies
2013-06-18 00:28:50 +01:00
2023-08-03 06:27:09 -07:00
- libtool
- make
- automake
- autoconf
2013-06-18 00:28:50 +01:00
2023-08-03 06:27:09 -07:00
#### Instructions
2014-06-04 18:29:30 -05:00
2023-08-03 06:27:09 -07:00
```console
2024-05-21 11:40:12 -03:00
git submodule update --init # if building from git to get oniguruma
autoreconf -i # if building from git
2023-08-03 06:27:09 -07:00
./configure --with-oniguruma=builtin
2024-05-21 11:40:12 -03:00
make clean # if upgrading from a version previously built from source
2023-08-03 06:27:09 -07:00
make -j8
make check
sudo make install
2026-10-23 19:33:07 -05:00
sudo ldconfig # on Linux, if jq cannot find libjq.so
2023-08-03 06:27:09 -07:00
```
2014-06-04 18:29:30 -05:00
2023-08-03 06:27:09 -07:00
Build a statically linked version:
2015-01-01 16:26:55 -06:00
2023-08-03 06:27:09 -07:00
```console
2026-10-23 19:33:07 -05:00
make clean
2023-08-03 06:27:09 -07:00
make LDFLAGS=-all-static
```
2015-01-01 16:26:55 -06:00
2023-08-03 06:27:09 -07:00
If you're not using the latest git version but instead building a released tarball (available on the release page), skip the `autoreconf` step, and flex or bison won't be needed.
2015-05-02 17:34:52 -05:00
2023-08-03 06:27:09 -07:00
##### Cross-Compilation
2023-07-19 08:04:39 -07:00
2023-09-27 02:49:07 +09:00
For details on cross-compilation, check out the [GitHub Actions file ](.github/workflows/ci.yml ) and the [cross-compilation wiki page ](https://github.com/jqlang/jq/wiki/Cross-compilation ).
2023-07-19 08:04:39 -07:00
2023-08-03 06:27:09 -07:00
## Community & Support
2023-06-01 10:09:39 -07:00
2023-08-03 06:27:09 -07:00
- Questions & Help: [Stack Overflow (jq tag) ](https://stackoverflow.com/questions/tagged/jq )
- Chat & Community: [Join us on Discord ](https://discord.gg/yg6yjNmgAC )
- Wiki & Advanced Topics: [Explore the Wiki ](https://github.com/jqlang/jq/wiki )
2023-06-01 10:09:39 -07:00
2023-08-03 06:27:09 -07:00
## License
2024-02-05 11:36:33 +01:00
`jq` is released under the [MIT License ](COPYING ). `jq` 's documentation is
licensed under the [Creative Commons CC BY 3.0 ](COPYING ).
`jq` uses parts of the open source C library "decNumber", which is distributed
under [ICU License ](COPYING )