jq is a stream, not a table
A filter takes one value and can return zero, one or many. A pipe feeds each output to the next filter, and a comma joins two streams. The result pane shows the whole stream, and the line above it counts the values.
Pikkola jq, tool No. 67
Paste an API response, an export or a config file. Write a jq filter or a JSONPath path, and the rows appear as you type: what matched, what type each value is, and a CSV to take away. The document stays in the tab.
checked against jq 1.7 on 157 queries
The playground
The document sits on the left. The query sits above the answer. Everything is evaluated in this tab as you type, with a pause of a quarter second so a long query does not run on every keystroke.
Press an entry to put it at the cursor. The sheet lists what this page implements, not all of jq.
No result yet. Pick a document and a query, or press one of the samples above.
Query error
No request, no account, no storage of the document. The Content-Security-Policy sets connect-src to none, so the page could not upload a record even if it tried.
Under the query
The query is read by a tokenizer and a recursive descent parser, then walked over the parsed JSON. No part of it is handed to eval or to the Function constructor, because this page runs under a policy that would refuse them anyway.
A filter takes one value and can return zero, one or many. A pipe feeds each output to the next filter, and a comma joins two streams. The result pane shows the whole stream, and the line above it counts the values.
The tokenizer knows where each token starts and each node keeps that position. A missing bracket, an unknown function or an index on a string is reported with the line and the column of the query, not with a stack trace.
The cheat sheet lists every function this page implements. Anything else stops with a message that names it, rather than returning a quiet null. Where a query is supported, its output is compared with jq 1.7 in the build.
Enough of jq for the work people actually bring to a JSON file, and a clear edge where the rest begins. JSONPath has its own, shorter list.
Reference
The same groups you get from the button in the studio, written out so a search engine can find them too. Each line is a query that works on the samples above.
The tool in front of you reads a document once, when you paste it. Watch reads up to ten domains every day and sends one message when a certificate slips, a page stops answering or a security header disappears. It is the same idea, pointed at a live site.
$7a month
$70 a year, two months free
See what Watch checksTen domains, one check a day, $0 to start on this page.
Made by one person, free to use
No. It is a jq style interpreter written in JavaScript for this page, and its output is compared with jq 1.7 on 157 queries in the build. The common filters, constructors, arithmetic, if, as, reduce and the list and string functions are here. def, foreach, label and input are not, and a query that uses them stops with its name instead of guessing.
No. The parser, the evaluator and the sample documents are files on this domain. The Content-Security-Policy sets connect-src to none, so there is no endpoint the page could reach, and a document is never written to storage.
jq calls its output a stream: a query can emit zero, one or many values. The page shows the whole stream. One value is shown as itself, several are shown as an array, and the line under the result says which one you are looking at. A filter that ends in .[] usually turns one array into many rows.
Use the CSV or TSV tab and press Copy or Download. When every row is an object, the columns are the union of the keys, in the order they first appear. A single array of objects becomes its rows. Values that are not scalars are written as JSON, and a value that holds a comma or a quote is quoted the way CSV expects.
Yes, with Open a file. The browser reads it, the page parses it, and it stays in the tab. It is not uploaded and it is not kept between visits. A JSON Lines file is not valid JSON; wrap the lines in an array first, or pick the sample that matches the shape.
A document of a few megabytes is comfortable. A query is stopped by a step budget before it can freeze the page, and a stream is capped at fifty thousand values, so a bare dot on a million records asks for a narrower query. When that happens the message says which limit was reached.
JSONPath is shorter when you only need to point at values: $..book[?(@.price < 10)].title. jq is a language: it can also rebuild objects, group, add and format. If the answer is a set of values, either works. If the answer is a new document, use jq.