jq Playground

Run jq filters on JSON in your browser, see the result as you type, and copy the matching command for your terminal.

Runs in your browser. Nothing is uploaded.

Updated

Filter and JSONRuns in your browser · jq 1.8.2

Example output. jq 1.8.2 loads when you change anything (about 0.9 MB, once).

Same command in a terminal
jq -r '.orders[].customer' data.json
Your text stays on this device. No upload required.

How to use jq Playground

  1. Type a jq filter, or pick an example.
  2. Paste JSON or open a .json file, and tick any flags you need.
  3. Copy the output, or copy the jq command for your terminal.

jq Playground at a glance

Typical use: Pull every customer name out of an API response, or turn a JSON array into CSV rows.

The real jq 1.8.2, running as WebAssembly in your browser; nothing is uploaded. Each run is limited to five seconds. --arg and modules are not available.

When to use jq Playground

jq is the command-line tool developers use to pull values out of JSON, filter it and reshape it. Its filter language is powerful but easy to get wrong, so this page lets you try filters on your own JSON and see the result as you type, with errors explained in plain English. When the filter works, copy the matching command.

It runs the real jq 1.8.2, compiled to WebAssembly, inside your browser. Your JSON and filters are never uploaded, and nothing is saved.

jq Playground examples

  • Names from an API response: .orders[].customer with -r prints Ana, Bilal and Chen on separate lines, without quotes, ready to paste into a list.
  • Only matching records: .orders[] | select(.total > 20) | {id, customer} keeps orders over 20 and only two fields of each.
  • JSON to CSV: .orders[] | [.id, .customer, .total] | @csv with -r gives one spreadsheet row per order.

jq cheat sheet

FilterWhat it does
.the whole input, pretty-printed
.name .a.b ."key with spaces"a field, a nested field, a field with an odd name
.[0] .[-1] .[2:4]first item, last item, a slice
.[] .items[]every item of an array (or value of an object)
a | bfeed the output of a into b
select(.age > 30)keep only items where the test is true
map(.price) [.[] | .price]transform every item into an array
{id, name} {total: .sum}build a new object
length keys add uniquecount, list keys, sum or join, remove duplicates
sort_by(.date) group_by(.type)sort or group by a field
.x // "default"use a fallback when .x is missing, null or false
.items[]?skip silently when .items is missing
"\(.id): \(.name)"build text from values
@csv @tsv @base64 @uriformat as CSV, TSV, Base64 or a URL part
del(.secret) .price |= . * 2remove a field, update a value in place

Prefer the terminal?

This page runs the real jq, so the same filter works in a terminal:

jq -r '.orders[] | select(.status == "paid") | .customer' data.json
curl -s https://api.example.com/items | jq '.[0]'

Install jq with brew install jq (macOS) or sudo apt install jq (Ubuntu). This page doesn’t support --arg, --argjson, modules or reading several files; jq 1.7 and older lack a few newer functions.

References

Frequently asked questions

Is my JSON uploaded or saved?

No. jq runs inside your browser, and files you open are read on your device. Filters and JSON are not sent to a server, saved, or put in the page address.

Is this the real jq?

Yes: jq 1.8.2 from jqlang, compiled to WebAssembly with Emscripten by the open-source jq-wasm project. Results match the jq command-line tool. The first time you edit something, the browser downloads it (about 0.9 MB) and then reuses it.

Why does my filter fail with “Cannot index array”?

The value is an array, and .name only works on objects. Add [] to go into each item: .users[].name instead of .users.name. The page explains common errors like this one under the message from jq.

What is the difference between -r, -c and -s?

-r prints strings without quotes, which is what you want for text and CSV. -c prints each result on one line. -s reads all the JSON values in the input into one array, which is useful for files with one JSON object per line.

My filter was stopped. Why?

Each run has a five-second limit and a memory limit, so a filter that loops forever (for example repeat or an endless recurse) or builds an enormous result can’t freeze your browser. Add a limit, such as limit(10; repeat(.)), or work on a smaller part of the data.

Can I use --arg or modules?

Not on this page. Write values straight into the filter instead, for example select(.id == 42). Modules (import and include) can’t be loaded either, because the engine has no access to files.