Tbh, this is something I struggled with for a while, so I hope it helps someone.
If you paste a draft email, client proposal, or unpublished blog post into a typical online word counter, you rarely know where that text goes. Many tools send your input to a backend endpoint just to count words and return a JSON response.
For a simple text utility, there is no reason for your writing to leave your machine. Everything needed to count words, characters, sentences, paragraphs, and reading time is already fast in plain JavaScript inside the browser.
That is the approach behind Tooltri Word Counter:** Useful when you only want the visible character count. honestly, 4. **Sentences:** Counts sentence endings (`.`, `!`, `?`) while treating sequences like `...` and `?!` as a single break instead of inflating the count. 5. **Paragraphs:** Counts text blocks separated by at least one blank line. 6. **Reading Time:** Estimates reading duration at 200 words per minute, rounded up (`< 1 min read` for short snippets, `0 min read` when empty).
in my experience, ## Keeping the Counting Logic Simple and Predictable
A common trap when writing a browser word counter is running heavy regex passes or re-rendering large components unnecessarily. Keeping the core calculation as a single pure function over the textarea string makes it instant even on long drafts:
function analyzeText(raw) {
const trimmed = raw.trim();
if (!trimmed) {
return {
words: 0,
characters: 0,
charactersNoSpaces: 0,
sentences: 0,
paragraphs: 0,
readingMinutes: 0,
};
}
const words = trimmed.split(/\s+/).length;
const characters = raw.length;
const charactersNoSpaces = raw.replace(/\s/g, "").length;
const sentences = (trimmed.match(/[^.!?]+(?:[.!?]+|$)/g) || []).length;
const paragraphs = trimmed.split(/\n\s*\n/).filter(Boolean).length;
in my experience, const readingMinutes = Math.ceil(words / 200);
return {
words,
characters,
charactersNoSpaces,
sentences,
paragraphs,
readingMinutes,
};
}
Two small details make a big difference in accuracy:
- Handling
...and?!: Matching[.!?]+as a group prevents ellipses or combined punctuation from counting as three separate sentences. - Handling blank lines: Splitting paragraphs on
\n\s*\navoids counting a single accidental line break inside a paragraph as a new paragraph.
When analysis stays on the client:
- Your text stays on your device. Nothing is uploaded, stored in a database, or logged.
- Updates feel instant. There is no network round-trip on each keystroke.
- Clearing state is immediate. Clicking Reset (or closing the tab) wipes the input from memory.
Below the editor, the page also includes a quick reference table for common targets across X, Instagram, LinkedIn, Google meta titles and descriptions, and blog posts, along with links to related tools like **Duplicate Word Finder**, **Text Case Converter**, **ChatGPT Text Cleaner**, and **Token Counter**.
You can try it here: [tooltri.com/word-counter](
What other writing or text utilities do you use regularly in your workflow?
Hopefully this saves someone a bit of debugging time. Catch you later!