jq Query Tester
Paste JSON, write a jq filter, and preview the transformed output instantly — entirely in your browser.
"Sapiens" "Atomic Habits"
Sample Expressions (click to try)
About the jq Query Tester
The jq Query Tester lets you write and evaluate jq filter expressions against any JSON document in real time. Paste your data, type a filter, and watch the transformed output update as you type — no page reload, no server round-trip.
jq is the de-facto standard command-line JSON processor, with a small but expressive functional language for slicing, filtering, mapping, and reshaping structured data. This tester runs entirely in your browser using a self-contained jq subset interpreter — your data never leaves your device.
Supported jq Syntax
| Operator / Function | Description | Example |
|---|---|---|
| . | Identity — current input | . |
| .foo | Field access | .store.books |
| .foo? | Optional access (no error on miss) | .maybe? |
| .[n] | Array index (negative allowed) | .[0], .[-1] |
| .[a:b] | Array / string slice | .[1:3] |
| .[] | Iterate over array or object values | .books[] |
| | | Pipe — chain filters | .a | .b |
| , | Comma — concatenate outputs | .a, .b |
| .. | Recursive descent | .. | .price? |
| [...] | Array construction (collect outputs) | [.books[].title] |
| {...} | Object construction | {title, price} |
| select(f) | Keep input where f is true | select(.price < 20) |
| map(f) | Apply f to each array element | map(.price) |
| length | Length of array, string, or object | .books | length |
| keys | Sorted keys of object / indices of array | .store | keys |
| sort, sort_by(f) | Sort an array | sort_by(.price) |
| group_by(f) | Group elements by key | group_by(.tags[0]) |
| unique, unique_by(f) | Remove duplicates | .tags | unique |
| min, max, add | Aggregations on arrays | [.qty] | add |
| to_entries / from_entries | Convert object ↔ key/value array | to_entries |
| if-then-elif-else-end | Conditional branching | if .a then 1 else 0 end |
| // (alt) | Alternative operator | .x // "default" |
| @csv, @json, @uri, @base64 | Format strings | @csv |
How to Use the jq Query Tester
- Paste your JSON into the JSON Input textarea, or click Sample Data to load an example document.
- Type a jq filter into the jq Filter Expression field at the top.
- The transformed output appears immediately in the Result panel on the right — no button click required.
- Use the Sample Expressions grid to apply common filters with one click.
- Click Pretty Print JSON to re-format the input, or Copy to grab the result.
- Filter errors and parse errors are shown inline in the red error panel so you can iterate quickly.
Common Use Cases
- Extract specific fields from API responses (e.g.
.data[].id). - Filter large JSON logs to entries matching a predicate (
select(.level == "error")). - Reshape data for CSV import —
[.id, .name, .price] | @csv. - Aggregate numbers — sum, min, max, or group rows by category.
- Pretty-print or compact JSON, validate structure, and explore deeply nested documents.
- Prototype jq commands here, then paste them into your terminal pipeline.
Frequently Asked Questions
What is jq?
jq is a lightweight, flexible command-line JSON processor created by Stephen Dolan in 2012. It treats JSON values as a stream and applies a small functional language of filters to slice, filter, map, and transform structured data. jq has become the standard tool for working with JSON in shell pipelines.
Does this tester run the real jq binary?
No — it runs a self-contained jq subset interpreter written in TypeScript that executes
entirely in your browser. It covers the vast majority of day-to-day jq operations
(field access, pipes, select, map, sort_by, group_by, to_entries, conditionals, string interpolation, format strings,
regex via test/match/sub/gsub, and more) without shipping a 600KB WASM blob.
What jq features are not supported?
User-defined functions (def), variable bindings inside complex
reduce/foreach loops, modules, path expressions in assignments (.a |= .b),
and some advanced builtins like limit / until are not implemented. For full jq, run the official binary locally.
Why does my filter return multiple lines of output?
jq filters are a stream: a single filter can emit zero, one, or many values. For example .books[] emits each book separately. Wrap the expression in [ ... ] to collect the results into a single array.
What's the difference between .foo and .foo??
Both access a field. .foo raises an error if the input is not an
object; .foo? swallows the error and emits no output instead.
Use the optional form when iterating over heterogeneous data.
How do I filter array items by a condition?
Combine .[] with select(...): .orders[] | select(.status == "shipped") emits only the shipped orders.
Wrap in [...] to keep them as one array.
Is my data sent to a server?
No. All JSON parsing and jq evaluation happens entirely in your browser. Your data never leaves your device, which makes this tool safe for confidential API payloads, internal logs, and sensitive data structures.
How do I sum a field across all records?
Collect the field into an array and pipe to add: [.orders[].qty] | add sums every qty.