Skip to main content

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 '[{"status":"ok"},{"status":"error"},{"status":"ok"}]' | jpq 'collections.Counter(el["status"] for el in this)'  # {"ok": 2, "error": 1}

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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jpq-0.1.6.tar.gz (31.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jpq-0.1.6-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file jpq-0.1.6.tar.gz.

File metadata

  • Download URL: jpq-0.1.6.tar.gz
  • Upload date:
  • Size: 31.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

File hashes

Hashes for jpq-0.1.6.tar.gz
Algorithm Hash digest
SHA256 2168354c418ed8ce60664f7aba86c893fe9d90bff87b81e1b60ef437e4dfd4cf
MD5 2f693802bfae3dbac8d8f29196a4948e
BLAKE2b-256 1cb99f447176797c0937999ae610b0bd6f9df9e26f44b6030902b5f1581869bd

See more details on using hashes here.

File details

Details for the file jpq-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: jpq-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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}

File hashes

Hashes for jpq-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1780899d3d52aacb4210eccdef2b38061bee29f66297b30b9eaa0f30887da34f
MD5 0e5b25d1e294a55ae8cc38e39206029d
BLAKE2b-256 ab6ffc62cadd784db99cf3fa8c170e6ab3efc8e66cfd26e7d6c9f0e7d7d3b9e5

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.1

2 files

0.2.0

2 files

This release

0.1.6 This release

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page