Categories We Write About

Build a reading time estimator

Here’s a simple Reading Time Estimator that calculates how long it will take someone to read a given text, based on an average reading speed.


🧠 Assumptions:

  • Average reading speed = 200–250 words per minute (wpm)

  • Estimation will be rounded to the nearest minute

  • Optional: Show word count


JavaScript Version (can be used in websites or web apps)

javascript
function estimateReadingTime(text, wordsPerMinute = 225) { const words = text.trim().split(/s+/).length; const minutes = Math.ceil(words / wordsPerMinute); return { wordCount: words, readingTime: minutes, readableText: `${minutes} min read` }; } // Example usage: const article = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...`; const result = estimateReadingTime(article); console.log(result.readableText); // e.g., "2 min read" console.log(`Words: ${result.wordCount}`);

Python Version (for scripts or backends)

python
import math def estimate_reading_time(text, words_per_minute=225): words = text.strip().split() word_count = len(words) reading_time = math.ceil(word_count / words_per_minute) return { 'word_count': word_count, 'reading_time': reading_time, 'readable_text': f"{reading_time} min read" } # Example usage: article = """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...""" result = estimate_reading_time(article) print(result['readable_text']) # "1 min read" print(f"Words: {result['word_count']}")

🧩 Optional Enhancements

  • Adjust reading speed for different languages or audiences

  • Detect and exclude code, metadata, or quotes

  • Use syllable count for more accuracy (e.g., with textstat in Python)

Let me know if you want it as a WordPress plugin, React component, or any other format.

Share This Page:

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories We Write About