ASKBlog
Sanity
1 min read
11.11.2025

Reading time sanity blog

Last updated: 11.11.2025

Reading time

Reading time estimates help readers decide if they have time to engage with your content. Here's how to add this feature to your Sanity-powered blog.

The Challenge

Sanity's block content (Portable Text) stores rich text as structured data, not plain strings. This means you can't simply count words in the traditional way.

Calculate in GROQ Query

The most efficient approach is to calculate reading time directly in your GROQ query:

1```groq
2*[_type == "post" && defined(slug.current)]{
3_id,
4title,
5slug,
6"minutesToRead": length(string::split(pt::text(body), " ")) / 200,
7
8}
9```

Finding the length of the block content using the pt::text() function splitting on space to get number of words dividing on 200 (average reading speed) to get minutes

The `pt::text()` function extracts plain text from Portable Text blocks.

Best Practice

For optimal performance, calculate reading time in GROQ queries. This reduces client-side JavaScript and improves load times.

The average reading speed of 200 words per minute is industry standard, but adjust based on your content's complexity.