jpq
jq-style JSON filtering, but with Python expressions.
The parsed stdin JSON is bound to this; the value of the expression is printed as JSON.
Install
From PyPI using uv (recommended):
uv tool install jpq
# alternatively (using pip/pipx):
# pipx install jpq
# pip install --user jpq
From source, after cloning:
uv tool install .
By building locally:
uv build
uv tool install ./dist/jpq-*.whl
Or run straight from the checkout without (re)installing:
$ echo '[1,2]' | uv run main.py 'this[0]' # 1
Usage
$ echo '{"name":"alice","age":30}' | jpq 'this["name"]' # "alice"
$ echo '[1,2,3,4,5]' | jpq 'statistics.mean(this)' # 3
$ echo '{"a": [{"b": 2}]}' | jpq 'this.a[0].b' # 2
$ echo '[{"status":"ok"},{"status":"error"},{"status":"ok"}]' | jpq 'collections.Counter(el["status"] for el in this)' # {"ok": 2, "error": 1}
Note that you can access dict keys as attributes, e.g. this.name instead of this["name"].
Missing attributes show the available keys when the object has fewer than 20 keys:
$ echo '{"name":"alice","age":30}' | jpq 'this.abcd'
jpq: AttributeError: abcd (available keys: ['name', 'age'])
Pre-imported in the eval namespace: re, collections, itertools, statistics, math, datetime, plus all builtins.
Run jpq --help for more.
Advanced examples
Pipe an API response through a multi-line expression to reshape it:
$ curl -s https://api.github.com/repos/python/cpython | jpq '
{
"now": (now:=datetime.datetime.now(tz=datetime.UTC)),
"stars": this["stargazers_count"],
"last_pushed_seconds_ago": (
now - datetime.datetime.fromisoformat(this["pushed_at"])
).total_seconds(),
}'
{
"now": "2026-05-13T15:05:11.746397+00:00",
"stars": 72668,
"last_pushed_seconds_ago": 566.746397
}
Note how the walrus operator (:=) is used to assign now and use it in the expression and how it is serialized to JSON via datetime fallback.
See more examples in the blog post about jpq.
Metadata
Release files for jpq 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jpq-0.3.1.tar.gz | 39.6 kB | Without provenance | Details for jpq-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jpq-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for jpq-0.3.1-py3-none-any.whl |
Total release size: 57.0 kB
Release files / jpq-0.3.1.tar.gz
| Download URL | jpq-0.3.1.tar.gz |
|---|---|
| Size | 39.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c68693b9fd800943e9d71ea1087c4ab1a0d9d00ec2bad0f1a5f12efd924e9ce
|
|
BLAKE2b-256 checksum How to use checksums |
0e6864d2f44b78bae01c5d3d6477d0c2b0d756645262f1de1d6957bb7d472956
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / jpq-0.3.1-py3-none-any.whl
| Download URL | jpq-0.3.1-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43d7b23d7aab144f5894ff1d3f9c083e11ae196af71db05a1a638aabe77f0823
|
|
BLAKE2b-256 checksum How to use checksums |
663ec85065a5f04fc520aac027a3bb969361071aab19c1a5825d6c46b8423e23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.22 {"installer":{"name":"uv","version":"0.12.22","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for jpq 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.