
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeHey! Happy to help you with GROQ! It's Sanity's query language for working with content, and once you get the hang of it, it's really powerful.
GROQ (Graph-Relational Object Queries) is Sanity's open-source query language designed specifically for filtering, fetching, projecting, joining, and transforming JSON documents from your Content Lake. Think of it as a way to ask for exactly the content you need, shaped exactly how you want it.
The fundamental pattern of a GROQ query looks like this:
*[filter]{projection}* = all documents (that you have permission to read)[filter] = which documents you want (optional){projection} = how to shape the results (optional)Here's a practical example that fetches directors born since 1970 with their movies:
*[_type == "director" && birthYear >= 1970]{
name,
birthYear,
"movies": *[_type == "movie" && director._ref == ^._id]
}It's a JSON superset: If you know JSON, you already understand part of GROQ's syntax. Any valid JSON is a valid GROQ query.
Pipeline-based: GROQ queries work as pipelines where results flow through each component. You can chain filters and projections together.
Whitespace doesn't matter: Format your queries however you like. You can also add comments with //.
Sanity has great resources to help you learn:
What specific aspect of GROQ are you trying to work with? The basics above should get you started, but there's a lot more depth available depending on what you're building!
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store