TypeScript icon, indicating that this package has built-in type declarations

1.10.0 • Public • Published


npm stat npm version gzip size size

GROQ-JS is a JavaScript implementation of GROQ which follows the official specification.

import {parse, evaluate} from 'groq-js'

let input = '*[_type == "user"]{name}'

// Returns an ESTree-inspired syntax tree
let tree = parse(input)

let dataset = [
  {_type: 'user', name: 'Michael'},
  {_type: 'company', name: 'Bluth Company'},

// Evaluate a tree against a dataset
let value = await evaluate(tree, {dataset})

// Gather everything into one JavaScript object
let result = await value.get()


Table of contents:


npm i groq-js
yarn add groq-js
pnpm install groq-js


See for the public API.

Learn GROQ

Free egghead GROQ introduction course by John Lindquist



The GROQ spec version is independent of the groq-js library version. When you import groq-js you need to be explicit on which GROQ version you want to use. The GROQ version is tied to the groq-spec. This allows us to update the library and its API independent of the GROQ version.


GROQ-JS follows SemVer. See the changelog for recent changes. This is an "experimental" release and anything may change at any time, but we're trying to keep changes as minimal as possible:

  • The public API of the parser/evaluator will most likely stay the same in future versions.
  • The syntax tree is not considered a public API and may change at any time.
  • This package always implements the latest version of GROQ according to the specification.

Releasing a new version of GROQ-JS

Run the "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Version will be automatically bumped based on conventional commits since the last release.

Semantic release will only release on configured branches, so it is safe to run release on any branch.

Note: commits with chore: will be ignored. If you want updated dependencies to trigger a new version, use fix(deps): instead.




Tests are written in Jest:

# Install dependencies
npm i

# Run tests
npm test

You can also generate tests from the official GROQ test suite:

# Fetch and generate test file:

# Run tests as usual:
npm test

You can generate tests from a specific version:


or from a file (as generated by the test suite):

GROQTEST_SUITE=suite.ndjson ./test/

The test arguments are passed to tap, so you can use arguments, e.g. to run a specific set of tests:

npm test -g "array::join"



Package Sidebar


npm i groq-js

Weekly Downloads






Unpacked Size

975 kB

Total Files


Last publish


  • tiit.kass.saity
  • christianhg
  • joan_miralles_paez
  • jwoods-sanity
  • armandocerna
  • daniel.malmer
  • jordanl17
  • tambet
  • jtpetty
  • drewsanity
  • refiito
  • sergeisarviro
  • ash
  • indrek.karner
  • cngonzalez-sanity
  • rdunk
  • rneatherway-sanity
  • ricokahler
  • pedro-sanity
  • jonabc
  • kenjonespizza
  • pauloborgesf
  • binoy14
  • simen.svale
  • svirs
  • josh_sanity_io
  • joneidejohnsen
  • nina.andal
  • rankers
  • snorreeb
  • mattcraig
  • vincentquigley
  • stipsan
  • michael-sanity
  • rubioz
  • tonina
  • ritasdias
  • simeonsanity
  • kmelve
  • bjoerge
  • rexxars
  • skogsmaskin
  • robinpyon
  • mariuslundgard
  • sanity-io
  • evenw
  • radhe_sanity
  • rbotten
  • judofyr
  • obliadp
  • dcilke
  • fredcarlsen
  • hermanw
  • sgulseth
  • atombender