humanonlyweb/writer

Word count

Words a reader sees, and minutes to read them.

Markdown
import { countWords, readingMinutes } from "@humanonlyweb/writer";

const words = countWords(markdown);
readingMinutes(words); // at least 1, at 230 words a minute
Copy code

countWords(markdown) counts words, and readingMinutes(words, wordsPerMinute = 230) turns them into minutes.

It counts what a reader sees: link text but not URLs, and no images, code, block fences, attributes, footnote labels or frontmatter. Chinese and Japanese count a word per character.

It's synchronous, fast enough for every keystroke, and gives the same answer on the server and in the browser, so it's safe to render during SSR. In Nuxt it's auto-imported on the server too: store it with the document.