Sanity
1 min read
11.11.2025

Reading time sanity blog

Last updated: 22.12.2025

Reading time
🎧

Audio Narration

Listen to this post

Reading time estimates are useful for readers to gauge their engagement time with content. For Sanity-powered blogs, calculating reading time is challenging due to Sanity's block content storing rich text as structured data. The recommended solution is to calculate reading time directly in a GROQ query. This involves using the pt::text() function to extract plain text from Portable Text blocks, splitting the text to count words, and dividing by 200 to estimate minutes to read, based on an average reading speed of 200 words per minute. Calculating reading time in GROQ queries enhances performance by reducing client-side processing and improving load times. Adjust the average reading speed based on the complexity of your content for more accurate estimates.

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.