You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ groq --help
Run GROQ in the command line
Usage
$ groq '*[<filter>]{<projection>}'# Remember to alternate quotation marks inside of the query
Options
-i, --input One of: ndjson, json, null
-o, --output One of: ndjson, json, pretty, type-nodes
-p, --pretty Shortcut for --output=pretty
-n, --ndjson Shortcut for --input=ndjson --output=ndjson
-s, --schema Path to a schema file, only required when output is set to "type-nodes"
Input formats
json Reads a JSON object from stdin.
ndjson Reads a JSON stream from stdin.
null Reads nothing.
Output formats
json Formats the output as JSON.
pretty Formats the output as pretty JSON.
ndjson Streams the result as NDJSON.
Examples
# Query data in a file
$ cat blog.json | groq 'count(posts)'# Query data in a NDJSON file
$ cat blog.ndjson | groq --input ndjson '*[_type == "post"]{title}'# Query JSON data from an URL
$ curl -s https://jsonplaceholder.typicode.com/todos | groq --pretty '*[completed == false]{title}'
Similar tools
GROQ-cli isn't the only tool to work with JSON data in the command line. If it doesn't do exactly what you need, you can check out these other tools that might help you:
jq — a lightweight and flexible command-line JSON processor.