Skip to content
All projects

Reading Time Estimator

Word count that understands markdown — skips code fences, counts images, handles CJK text.

typescriptmarkdownnpm

Naive text.split(' ').length / 200 is wrong for technical writing. A post that is half code reads nothing like a post that is all prose.

Adjustments it makes

  • Code blocks counted at a slower rate — code is read, not skimmed
  • Images add a flat twelve seconds each
  • CJK text counted by character, since spaces are not word boundaries
  • Markdown syntax stripped before counting, so link URLs do not inflate the total
readingTime(markdown) // { minutes: 7, words: 1420, text: '7 min read' }

No dependencies, works in Node and the browser.