Eskillsfy

Home / Blog / Text

Text · 23 Nov 2026

Word & Character Counter: how it works and how to build one

Count words, characters, sentences and reading time. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

See words, characters with and without spaces, sentences, paragraphs and estimated reading and speaking time as you type. The most used words are listed too, which helps when writing titles and meta descriptions.

When to use it

  • Essays with a word limit
  • Social posts
  • SEO titles and descriptions

How to use it

  1. Type, paste or open a text file.
  2. Counts update live.
  3. Check the top words and the length limits for titles and descriptions.

Try it free in your browser, nothing is uploaded: https://eskillsfy.com/tools/word-counter

How it works

Counting words sounds easy, but punctuation and other scripts make it tricky. The counter uses Intl.Segmenter, which splits text into words the way a language does, including Hindi and Chinese.

Reading time assumes about 230 words per minute; speaking time about 140. Character limits for tweets and meta descriptions are simple length checks.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any TypeScript or JavaScript project.

count.ts (ts)

export function countWords(text: string) {
  const seg = new Intl.Segmenter(undefined, { granularity: "word" });
  const words = [...seg.segment(text)].filter((s) => s.isWordLike).length;
  const sentences = [...new Intl.Segmenter(undefined, { granularity: "sentence" }).segment(text)].filter((s) => s.segment.trim()).length;
  return {
    words, sentences,
    characters: [...text].length, // counts emoji as one
    noSpaces: text.replace(/\s/g, "").length,
    readingMinutes: Math.ceil(words / 230),
  };
}

Make it production-ready

  • Show the most used words.
  • Highlight text past a chosen limit.

Questions

How is reading time worked out?

At 230 words per minute, a common average for adults reading on screen.

Try the Word & Character Counter

Free, runs in your browser, nothing is uploaded.

Open it
Keep reading

More in Text

All posts