Skip to content


Repository files navigation

License (3-Clause BSD) Kotlin bld Release Maven Central Nexus Snapshot

Quality Gate Status GitHub CI CircleCI

Estimated Reading Time for Blog Posts, Articles, etc.

A simple implementation of Medium's Read Time calculation.

Examples (TL;DR)

import net.thauvin.erik.readingtime.ReadingTime

// ...

val rt = ReadingTime(htmlText)
println(rt.calcEstimatedReadTime()) // eg: 2 min read

To get the estimated reading time in seconds use the calcReadingTimeInSec() function.


To use with bld, include the following dependency in your build file:

repositories = List.of(MAVEN_CENTRAL);


Be sure to use the bld Kotlin extension in your project.

Gradle, Maven, etc.

To use with Gradle, include the following dependency in your build file:

repositories {

dependencies {

Instructions for using with Maven, Ivy, etc. can be found on Maven Central.


The following properties are available:

    wpm = 275,
    postfix = "min read",
    plural = "min read",
    excludeImages = false, 
    extra = 0,
    roundingMode = RoundingMode.HALF_EVEN
Property Description
text The text to be evaluated. (Required)
wpm The words per minute reading average.
postfix The value to be appended to the reading time.
plural The value to be appended if the reading time is more than 1 minute.
excludeImages Images are excluded from the reading time when set.
extra Additional seconds to be added to the total reading time.
roundingMode The rounding mode to apply.


A couple of useful functions are also available:

ReadingTime.wordCount(htmlText) // Returns the count of words. (HTML stripped)
ReadingTime.imgCount(htmlText) // Returns the count of images. (HTML img tags)


A JSP tag is also available for easy incorporation into web applications:

<%@taglib uri="" prefix="t"%>
    postfix="min read"
    plural="min read"

None of the attributes are required.


In addition to setters, a configuration builder is also available:

final ReadingTime rt = new ReadingTime(text);
rt.setPostfix("minute to read");
rt.setPlural("minutes to read");


final Config config =
        new Config.Builder(text)
                .postfix("minute to read")
                .plural("minutes to read")
final ReadingTime rt = new ReadingTime(config);


If you want to contribute to this project, all you have to do is clone the GitHub repository:

git clone

Then use bld to build:

cd readingtime
./bld compile

The project has an IntelliJ IDEA project structure. You can just open it after all the dependencies were downloaded and peruse the code.