Word Counter
Paste or type your text below to instantly count words, characters, sentences, paragraphs and get reading time.
Advertisement
Advertisement
Tips for using the word counter
This tool is perfect for checking essay word limits, article lengths, social media posts, and assignment requirements. The reading time estimate is based on an average reading speed of 200 words per minute.
function countWords(text) {
const words = text.trim() === '' ? 0 : text.trim().split(/\s+/).filter(w => w.length > 0).length;
const chars = text.length;
const charsNS = text.replace(/\s/g,'').length;
const sentences = text.split(/[.!?]+/).filter(s => s.trim().length > 0).length;
const paragraphs = text.split(/\n\s*\n/).filter(p => p.trim().length > 0).length || (text.trim().length > 0 ? 1 : 0);
const readMin = Math.max(1, Math.ceil(words / 200));
const readSec = words < 20 ? `${Math.ceil(words * 0.3)}s` : `${readMin} min`;
document.getElementById('s-words').textContent = words.toLocaleString();
document.getElementById('s-chars').textContent = chars.toLocaleString();
document.getElementById('s-chars-ns').textContent = charsNS.toLocaleString();
document.getElementById('s-sentences').textContent = sentences;
document.getElementById('s-paragraphs').textContent = paragraphs;
document.getElementById('s-reading').textContent = readSec;
// Top words
if (words > 0) {
const wordArr = text.toLowerCase().match(/\b[a-z]{3,}\b/g) || [];
const freq = {};
wordArr.forEach(w => freq[w] = (freq[w]||0)+1);
const stopWords = ['the','and','for','that','this','with','have','from','they','will','been','are','was','were','had','but','not','you','all','can','her','him','his','its','our','out','who'];
const top = Object.entries(freq).filter(([w]) => !stopWords.includes(w)).sort((a,b)=>b[1]-a[1]).slice(0,8);
document.getElementById('density-list').innerHTML = top.map(([w,c]) =>
`