Test jq Filters on JSON
online, free & instant
Query, filter, and extract data from JSON using jq-style expressions. Wildcards, recursive descent, array slicing, and conditional filters — all in your browser.
Open jq PlaygroundFilter JSON in three steps
No account. No upload. No nonsense.
No Server
Your JSON never leaves your device. There is no backend to send it to.
Zero Dependencies
Single self-contained HTML file. No frameworks, no CDN calls, nothing to break.
Works Offline
Load once and use forever — even on a plane or without internet access.
Related JSON tools
Common questions answered
What is jq and how does this playground work?
jq is a command-line JSON processor. This online playground provides similar filtering capabilities using JSONPath syntax — you can query, filter, and extract data from JSON without installing anything.
What filter syntax does the playground support?
The playground supports JSONPath syntax including dot notation ($.store.book), wildcards ($..* and [*]), array slicing ([0:3]), recursive descent (..), and conditional filters (?(@.price<10)).
Can I filter JSON arrays by a condition?
Yes. Use filter expressions like $.store.book[?(@.price<10)] to select array elements matching a condition. Supports ==, !=, <, >, <=, >= comparisons.
How is JSONPath different from jq syntax?
jq uses pipe-based syntax (.store.book[] | select(.price<10)) while JSONPath uses path expressions ($.store.book[?(@.price<10)]). Both achieve similar results — this tool uses JSONPath, which is widely supported in APIs and tools.
Is my JSON data secure in the playground?
Yes. All filtering and querying happens in your browser — no data is ever sent to a server. The tool works fully offline after the first load.
What is jq?
jq is a command-line JSON processor for filtering, transforming, and formatting JSON in shell pipelines. Its syntax is concise: .users[] | select(.active) | .name extracts names of active users. jq is installed on many Linux distributions and is the standard for processing JSON in scripts and CI/CD pipelines.
This playground lets you test jq-style expressions in your browser without installing anything. jq supports object construction, array manipulation, conditionals, string interpolation, regular expressions, and user-defined functions. It is useful for ad-hoc data extraction from API responses, log files, and configuration dumps.
// Data
{"users":[
{"name":"Alice","active":true},
{"name":"Bob","active":false},
{"name":"Charlie","active":true}
]}
// Query: .users[] | select(.active) | .name
"Alice" "Charlie"
Get the most out of this tool
- Use .field to access a key, .[] to iterate an array, and | (pipe) to chain transformations — the core jq workflow.
- select(.field == "value") filters array elements by condition — equivalent to SQL WHERE clause.
- Use @csv or @tsv output formatters to convert JSON arrays directly into spreadsheet-compatible formats.
Understanding jq — the JSON command-line processor
jq is a lightweight, flexible command-line tool for processing JSON data, written by Stephen Dolan and released in 2012. Often described as "sed for JSON", jq enables field extraction, filtering, transformation, and aggregation of JSON data directly in the terminal. Unlike general-purpose scripting languages, jq's filter language is specialized for JSON manipulation, making common operations like field extraction, array mapping, and conditional filtering expressible in compact one-liners.
The identity filter . is jq's simplest expression — it outputs the input unchanged but with pretty-printing applied. This makes jq '.' the most common use of jq: formatting minified JSON from curl output into readable indented format. Combined with curl, curl -s https://api.example.com/data | jq '.' is a staple command for inspecting API responses in the terminal.
Field access in jq uses dot notation: .name accesses the name field of the root object, and .user.email navigates two levels deep. Array indexing uses bracket notation: .[0] accesses the first element. The .[] iterator (without index) expands an array or object, outputting each element on a separate line — fundamental for processing JSONL streams where each input is one array element.
The pipe operator | chains transformations. .users | .[] | .name takes the users array, iterates over its elements, and extracts each element's name field. This pipeline model allows complex transformations to be composed from simple, understandable steps. The select function select(condition) filters to elements matching a condition: .[] | select(.active == true) outputs only active elements.
jq's map() function transforms every element of an array. map(.price * .quantity) multiplies price by quantity for every element in an array. map(select(.status == "active")) is equivalent to filtering with select but preserves the array wrapper. map({name: .name, total: (.price * .quantity)}) creates new objects by projecting and computing fields from each element.
Aggregation with jq uses built-in functions like add, length, min, max, unique, and group_by. [.[] | .price] | add sums all prices in an array. group_by(.category) | map({category: .[0].category, count: length}) groups by category and counts items in each group. These patterns enable data analysis operations without leaving the terminal or writing a Python script.
JSONL (newline-delimited JSON) processing is a jq specialty. The --slurp (-s) flag collects all input lines into one array before applying the filter — useful for cross-record operations. Without --slurp, jq applies the filter to each input line independently — useful for per-record transformations. The --raw-output (-r) flag outputs string values without JSON double-quote wrapping, making extracted values usable directly in shell scripts.
Real-world uses for jq
TOKEN=$(curl -s /auth | jq -r '.token') extracts an authentication token string that can be used directly in variable assignment without JSON parsing code.
cat app.log | jq 'select(.level == "ERROR") | .message' extracts error messages from a structured log file. Combining jq with sort | uniq -c | sort -rn produces frequency counts of error types without custom tooling.
kubectl get pods -o json | jq '.items[] | {name: .metadata.name, status: .status.phase}' extracts pod names and statuses from verbose API output. Combined with shell loops, jq filters enable complex cluster automation without custom tooling or SDK code.
jq usage pitfalls
- Using . when .[] is needed:
.outputs the whole array as-is;.[]iterates over elements. If you want to apply a filter to each element, use.[] | filterormap(filter). A common mistake is writing. | .nameexpecting to get names from array elements — this fails because.is the entire array, which has nonamefield. - Forgetting -r for string output in scripts: Without
--raw-output(-r), jq wraps string values in double quotes in its output —"value"instead ofvalue. Shell variable assignment will include the quotes:TOKEN="\"abc123\"". Always use-rwhen extracting string values for shell variable assignment or use in other commands. - Null propagation surprises: jq propagates
nullsilently. If a field doesn't exist, accessing it returnsnull, and further operations onnulloften also returnnull. Use// "default"(alternative operator) to provide fallback values:.name // "unknown"returns "unknown" ifnameis null or missing. - Single quotes in shell on different platforms: jq filters should be wrapped in single quotes in shell to avoid shell interpolation of special characters. On Windows cmd.exe and PowerShell, single quotes are not string delimiters — use double quotes and escape internal double quotes. Use a jq playground tool to test filters before embedding them in cross-platform scripts.
Additional frequently asked questions
How do I install jq on my system?
On macOS, install with Homebrew: brew install jq. On Ubuntu/Debian Linux: sudo apt-get install jq. On Windows, use Chocolatey (choco install jq), Winget (winget install jqlang.jq), or download the binary from jqlang.github.io/jq. jq is a single binary with no runtime dependencies — download the binary directly and place it in your PATH for immediate use.
What is the difference between jq and JSONPath?
jq is a full-featured command-line data transformation language with functions, variables, conditionals, and reduce/foreach operations. JSONPath is a query language focused on selecting values by path expression. jq can transform data into entirely new shapes; JSONPath primarily extracts existing values. For simple field extraction, both work well. For data transformation and aggregation, jq is significantly more powerful.
Can jq handle invalid or malformed JSON?
No — jq requires valid JSON input. If the input contains syntax errors (trailing commas, single quotes, comments), jq will report a parse error and exit. Use a JSON repair tool to fix the JSON first, or use jq's --raw-input (-R) flag to treat each line as a raw string and then apply parsing with try fromjson to handle mixed-validity input.
How do I use jq in JavaScript without the command-line tool?
The jq-web package provides jq compiled to WebAssembly, enabling jq filter execution in the browser or Node.js. Alternatively, node-jq wraps the native jq binary for Node.js. For most JavaScript use cases, JSONPath libraries or native JavaScript array methods (filter, map, reduce) are more practical than running jq in a Node.js context.