Skip to content
Sanity
Get started
  • Sanity Studio - Flexible editing environment
  • Content Lake - Real-time database
  • Developer experience - Tooling you love
  • Structured content - The philosophy behind Sanity
  • Review changes - View edits & rollback instantly
  • Image pipeline - On-demand transformations
  • E-commerce - Better shopping experiences
  • Marketing sites - Control your story
  • Products & services - Innovate and automate
  • Mobile apps - Content backend for every OS
  • Aether - Unique digital shopping experience
  • Morning Brew - Omnichannel media distribution
  • InVision - Delivering exceptional customer experiences
  • DataStax - Personalization for global audience
  • React
  • Gatsby
  • Next
  • Nuxt
  • Eleventy
  • Netlify
  • Vercel
  • Algolia
  • Documentation
  • Reference
  • Guides
  • Resource library
  • Headless CMS
  • Tools & plugins
  • Project showcase
  • Schemas & snippets
  • Agency partners
  • Technology partners
  • Get support
  • Share your work
  • How I Learned to Expect More From My CMS
EnterprisePricing
Contact salesLog inGet started
Published September 15th 2022

Content is Queryable: (Re)Introducing GROQ

Learn more about the query language we didn’t want to invent, as well as our plan to support GROQ into the future.

Simen Svale

Co-founder and CTO at Sanity.io

Today, we’re pleased to announce that GROQ, our open-source query language for content, is formalized as a working language specification. Teams can now more confidently rely on support for the language and associated tooling as a critical aspect of Sanity. If you use Sanity and GROQ today, be sure to check out this post outlining the thinking behind the GROQ language specification versioning, as well as an overview of new functions introduced to GROQ and our tooling.

Why GROQ?

We invented GROQ because we realized most so-called "Content APIs" out there were poorly executed. Even today, most CMSes tend to design content APIs around outdated website patterns, making it hard for content teams to deliver remarkable and sustainable digital experiences. At Sanity, we believe content should be treated as data. GROQ is an example of this. It lets you query any collection of JSON documents and filter them down to exactly what you need by their properties and value. And it lets you reshape and reform that data, using projections and functions.

It was never the goal to invent a new query language for content. But our team didn’t find an API pattern that met the criteria for making it easy to query connected content in JSON documents freely. We believe developers should be able to combine and reshape content to fit an evolving, creative set of experiences. And to do so without having content creators regularly re-author existing content for new uses, like creative ideas for more immersive newspaper stories, or more expressive and varied product pages in online stores. Awesome ideas are often dialed back due to so-called practical technical limitations. We all deserve better.

GROQ provides unprecedented freedom in how you power content-driven experiences. Developers can rapidly produce digital experiences for any channel, thanks to the more flexible design approach GROQ provides when working with structured content. We have seen countless projects where GROQ improves code readability, saves development time, and provides powerful functions for combining, transforming, and retrieving content for a wide variety of use cases.

Supporting our developer ecosystem

We avoid proprietary standards and vendor lock-in wherever we can, so GROQ has been a documented, open-source language for years. We also open-sourced our parser compiler, Glush. We have been humbled to see the response from the developer community, including the creation of guides, courses, sample code, and plugins to work with GROQ. All of these materials have helped with its adoption in the wider content ecosystem.

GROQ has been available on GitHub as a working draft for a couple of years while we’ve worked with our customers and community to learn how they use it. Taking these learnings, we have formalized a versioning scheme to conform the GROQ implementation in the Content Lake API version with other GROQ tooling, such as the JavaScript library groq-js. If you’re into language specifications, find the latest revision of the GROQ spec and future updates here.

New GROQ features!

In addition to GROQ’s new spec release structure, we’ve introduced new functions for developers. For example, as defined in GROQ-1.revision1, developers can now use new array functions to find distinct values and remove null values, string functions, and math functions like sum() to rapidly compute against content. To learn more and see an example, check out this technical blog post on GROQ’s new features. All of these features were prioritized thanks to feedback from our community.

Existing Sanity customers can use these new GROQ features with their content on Content Lake API version v2022-03-13 and v2021-10-21. If you are new to Sanity and want to experience a modern CMS that treats content as data, get started here.

Page content

  • Why GROQ?
  • Supporting our developer ecosystem
  • New GROQ features!

Platform

Structured ContentDeveloper experienceContent LakeSanity StudioSecurity & Compliance
  • Sanity vs Contentful
  • Sanity vs Strapi
  • Sanity vs Adobe Experience Manager
  • Sanity vs Hygraph
  • Sanity vs Sitecore
  • Sanity vs Storyblok
  • Sanity vs Contentstack
  • Sanity vs Prismic
  • Sanity vs Drupal

Resources

Documentation
  • React Blog
  • Gatsby Blog
  • Next.js Landing Pages
  • Progressive Web Application
  • Single Page Application
  • Svelte & Typescript App
  • Vue & Tailwind Blog
  • Developer Portfolio Templates
  • Form validation with Yup
  • Live Preview with Next.js and Sanity.io
Resource library
  • Agency partners
  • Technology partners
  • Blog Template
  • Personal Website Template
  • Developer Portfolio Templates
  • All Templates
Case Studies
  • Headless CMS
  • What is an API CMS
  • Static Sites 101
  • Headless SEO
  • Localization
  • GraphQL vs REST
  • What is a DXP?
  • Typescript 101
  • React CMS
  • Next.JS CMS
  • CMS for Shopify
  • Content platform
  • Multilingual CMS
  • Static Site CMS
  • Gatsby CMS
  • Node CMS
  • E-commerce CMS
  • Vue CMS
  • Angular CMS
  • GraphQL CMS
  • Newspaper CMS
  • Magazine CMS
  • Mobile apps CMS

Company

Contact SalesEnterpriseCareersTerms of ServiceAccessibility Statement

Stay connected

  • GitHub
  • Slack
  • Twitter
  • YouTube
  • Stack Overflow
  • Blog RSS
  • Newsletter
©Sanity 2023