How to query all items of a specific _type in Sanity

16 replies
Last updated: Jan 28, 2026
Or better yet how can I query ALL items of _type ?
AI Update

To query all documents of a specific type in GROQ, you can use a simple filter pattern. Here's the basic syntax:

*[_type == "yourTypeName"]

The * returns all documents, and the filter [_type == "yourTypeName"] keeps only documents where the _type field matches your specified type.

For example, to get all blog posts:

*[_type == "post"]

To get all authors:

*[_type == "author"]

You can also add projections to shape the returned data:

*[_type == "post"]{
  _id,
  title,
  publishedAt,
  author->
}

This follows the fundamental GROQ query pattern of *[<filter>]{<projection>}, where:

  • * fetches all documents you have permission to read
  • The filter [] keeps only matching documents
  • The projection {} shapes what fields are returned

If you want to retrieve all documents regardless of type, you can simply use:

*

Or with a projection to see their types:

*{_type, _id, title}

You can test these queries using the Vision plugin in your Sanity Studio, which provides a visual interface for experimenting with GROQ queries and seeing results in real-time.

Show original thread
16 replies

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?