jq Playground
Paste JSON and type a jq filter. The real jq 1.8 runs on it, marks each match and explains each error. Files up to 80 MB, no 1 MB limit. Nothing leaves your browser.
- 0
- Matches
- 0
- Steps
- 0
- Errors
On this page
About jq Playground
Updated
jq Playground runs jq filters on your JSON, in your browser. It is the real jq 1.8.2, compiled to WebAssembly, so a filter that works here works the same in your shell. Each value the filter takes from the JSON gets a mark there, and the Paths view gives its jq path.
jq's own errors are short: "syntax error, unexpected end of file". This page adds the place and a fix: a missing ), a single quote where jq wants a double one, a variable with no value. For a JSONPath and not a jq filter, use the JSONPath Tester.
Not sure which tool to use? See the best JSON formatters compared.
How to use jq Playground
- Paste JSON in the editor, or drop a file. JSON Lines (one value per line) works too.
- Type a filter in the bar above the JSON, for example
.[] | .name. The chips under the bar give filters that fit your JSON. - Set flags in Options: Raw output (
-r), Compact (-c), Slurp (-s), Null input (-n) and jq arguments for--arg. - Read the output in Result. Paths lists where each value came from; click a row to mark it in the JSON.
- The terminal icon at the end of the bar copies the filter as a jq command for bash, with your flags. The link icon copies a share link.
jq filters to start with
| Filter | What it does |
|---|---|
. | All of the JSON, formatted |
.user.name | The value of a key inside a key |
.[], .[0] | Each item of a list, the first item |
.[] | select(.age > 30) | The items that pass a test |
{name, email} | A new object with two keys |
[.[] | .tag] | unique | A list of the values, sorted, each once |
length, keys | How many items, which keys |
map(.price) | add | The sum of one field |
Common errors
A select( with no closing )
jq says "unexpected end of file". The arrow here shows where the bracket goes, and Fix adds it.
.store.book[] | select(.price < 10 | .titleTool:Add ) before |. The ( at column 23 is never closed. A ) here closes it before the next step.
.store.book[] | select(.price < 10) | .titleSingle quotes around a string
In a shell the whole filter sits in single quotes. Inside the filter, strings take double quotes.
.[] | select(.role == 'admin')Tool:Use " for strings. jq strings take double quotes.
.[] | select(.role == "admin")Cannot index array with "name"
The filter asks a list for a key. Take each item with [] first.
.data.nameTool:An array has no key "name". Take each item first.
.data[].namejq resources
- jq ManualEvery jq filter, function and flag, for the current version.
- jq TutorialA short start with the GitHub API: pipes, select and building objects.
- jq on GitHubThe source, the releases for Linux, macOS and Windows, and the issues.
- jq CookbookRecipes from the jq wiki: group, merge, flatten and convert.
- jq-wasmThe real jq compiled to WebAssembly. This page runs it in your browser.
- RFC 9535: JSONPathThe JSONPath standard, for when a tool or library asks for a path and not a jq filter.
jq FAQ
What is the jq command for?
jq reads JSON and changes it with a filter you write. It picks values out, keeps the items that pass a test, builds new objects, counts, sorts, and turns JSON into CSV or plain text. People use it most with the output of curl, kubectl and aws, in a shell or a script.
How do I use jq?
On a command line: curl -s https:. The part in quotes is the filter; jq runs it on the JSON it gets. Here, paste the JSON in the editor and type the filter in the bar above it: the output updates as you type.
Start with . (all of it), then go deeper with ., take each item with [], and join steps with |. select(. keeps the items that pass a test.
What is jq on Linux?
A small command-line program, one file with no dependencies, for Linux, macOS and Windows. Install it with sudo apt install jq on Debian and Ubuntu, brew install jq on macOS, or winget install jqlang. on Windows. This page runs the same jq, compiled to WebAssembly, so you can try a filter before you put it in a script.
How do I turn JSON into CSV with jq?
Make one list per row, then pipe it to @csv, and turn on Raw output (the -r flag), so the lines are not wrapped in quotes: .. Add a header row first: ["id","name","email"], (..
For CSV with nested data and no filter to write, use JSON to CSV.
Why does jq say Cannot index array with "name"?
The filter asks a list for a key. . fails when data is a list of users: a list has items, not keys. Take each item first: ., or . for the first one.
The opposite error, Cannot index object with number, means [0] on an object. Check what the data holds at that step: delete the last part of the filter and look at the output.
What is the difference between jq and JSONPath?
jq is a small programming language for the command line: it selects, and it builds new JSON. JSONPath only selects, and it is what libraries and tools take: kubectl, Postman, Jayway and AWS Step Functions. To test a JSONPath on the same JSON, use the JSONPath Tester.
Is my JSON uploaded?
No. jq runs in your browser as WebAssembly. Nothing is sent to a server. A share link keeps the data after the # of the address, and a browser never sends that part to a server.