Registry / serialization / jq
library1.12.0pypypi✓ verified 24d ago

jq is a lightweight and flexible JSON processor. This Python library provides robust bindings to the native `jq` C library (version 1.8.1), allowing Python applications to compile and execute `jq` programs for efficient JSON manipulation, filtering, and transformation. Currently at version 1.11.0, the project maintains an active release cadence with regular updates.

pip install jq
INSTALL
IMPORT
SIG · JQ
J
jq
serializationpythonv1.12.0
Install
1.6s avg
Import
10ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.12.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.010s · 19.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.008s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jq
import jq

This quickstart demonstrates compiling a `jq` program and applying it to both single JSON values and lists of values using the recommended `input_value()` and `input_values()` methods. It then retrieves the first or all results.

import jq json_data = {"name": "Alice", "age": 30, "city": "New York"} # Compile a jq program to extract the name and add a greeting compiled_program = jq.compile(".name | ""Hello, \(. )!""") # Process a single JSON value result = compiled_program.input_value(json_data).first() print(result) # Example with a list of values list_data = [{"value": 1}, {"value": 2}] compiled_list_program = jq.compile(".value + 10") results_list = compiled_list_program.input_values(list_data).all() print(results_list)
jq --version
Debug
Known issues
deprecatedThe `input()` method on compiled `jq` programs is older and deprecated. It can accept a valid JSON value as a positional argument or unparsed JSON text via the `text` keyword argument.
fix
Use `input_value()` for valid Python JSON values, `input_text()` for raw JSON strings, and `input_values()` for iterable sequences of Python JSON values. These methods offer clearer intent and better error handling.
affects: <1.5.0 (for primary use), but generally discouraged in all newer versions.
gotchaWhen `pip install jq` is performed without pre-built wheels available for your specific Python version and architecture, the package attempts to build from source. This requires native development tools (e.g., `autoconf`, `automake`, `libtool`, `build-essential` on Linux, Xcode command line tools on macOS) and Python development headers to be installed on your system.
fix
Ensure the necessary system-level build dependencies are installed before running `pip install jq`. Alternatively, set the environment variable `JQPY_USE_SYSTEM_LIBS=1` during installation to link against a pre-installed system `libjq` and `libonig` (requires these libraries to be available on the system).
affects: All versions, when wheels are not available.
gotchaThere are multiple Python bindings for `jq`, notably `jq` (mwilliamson/jq.py) and `pyjq` (doloopwhile/pyjq). These libraries are incompatible and have different APIs. Accidentally installing or importing the wrong one can lead to unexpected errors.
fix
Be mindful of which `jq` binding you intend to use. This entry pertains to `mwilliamson/jq.py`, installed via `pip install jq`. If using `pyjq`, refer to its specific documentation and `pip install pyjq`.
affects: All versions, due to naming collision.
gotchaCertain `jq` language constructs, such as `first`, `last`, `nth(n)`, and excessive `slurping` without proper optimization, can lead to inefficient or unexpected behavior in complex `jq` programs, especially with large datasets.
fix
Review `jq` best practices for performance. Avoid recomputing intermediate results, use variables (`$var`) for caching where appropriate, and prefer simpler filters or Python-side logic if `jq` expressions become overly complex or inefficient.
affects: All versions (pertains to `jq` language efficiency).
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jq'
The 'jq' Python package is not installed in your current Python environment.
fix
Install the package using pip: `pip install jq`.
RuntimeError: jq: error (at <stdin>:1): Cannot index array with string "..."
Your jq program is attempting to access an array element using a string key, when it expects an integer index or the current JSON structure at that point is an array, not an object.
fix
Review your JSON data structure and the jq program. If the data is an array, use integer indices (e. [0]) or the array iterator (e.g., .[]). If the field might be optional or sometimes an array/object, use the optional operator (e.g., .id?) or type checking (e.g., if type=="array" then .[] else .id end).
RuntimeError: jq: error (at <stdin>:1): Invalid program
The jq expression provided to `jq.compile()` contains a syntax error or is malformed.
fix
Carefully check the jq program string for syntax errors. Test the jq expression on the command line first to ensure it's valid before using it in Python.
RuntimeError: jq: error (at <stdin>:1): Expecting value: line X column Y (char Z)
The input JSON provided to the jq program is malformed or invalid, preventing jq from parsing it correctly.
fix
Ensure that the input data passed to `input_value()` or other input methods is valid JSON. Use a JSON validator or `json.loads()` in Python to identify and fix issues like missing commas, unquoted keys, or incorrect data types.
Upgrade
Version history
1.12.0latest on PyPI · released Jul 10, 2026
Audit
Dependencies
jq (C library)optionalThe Python `jq` package provides bindings to the native `jq` C library. While pre-built wheels typically bundle this C library, installing from source or explicitly setting `JQPY_USE_SYSTEM_LIBS=1` will require a system-wide installation of `libjq` and `libonig`.
Agent activity
7 hits · last 30 days
node
6
Resources
jq — pip install jq · libregistry