Cost Performance Index Calculator

SEO Word & Density Counter

Paste your content below to analyze word count and top keyword density.

Word Count 0
Characters 0

Top Keywords Density:

function analyzeText() { var text = document.getElementById('seo-input-text').value; var resultsDiv = document.getElementById('seo-results'); var wordCountEl = document.getElementById('res-word-count'); var charCountEl = document.getElementById('res-char-count'); var keywordListEl = document.getElementById('keyword-list'); if (!text.trim()) { resultsDiv.style.display = 'none'; return; } var cleanText = text.toLowerCase().replace(/[^\w\s]/gi, "); var words = cleanText.split(/\s+/).filter(function(w) { return w.length > 2; }); var totalWords = text.trim().split(/\s+/).length; wordCountEl.innerText = totalWords; charCountEl.innerText = text.length; var counts = {}; for (var i = 0; i < words.length; i++) { var word = words[i]; counts[word] = (counts[word] || 0) + 1; } var sortedKeys = Object.keys(counts).sort(function(a, b) { return counts[b] – counts[a]; }); var topKeywordsHtml = ''; var limit = Math.min(sortedKeys.length, 5); for (var j = 0; j < limit; j++) { var kw = sortedKeys[j]; var count = counts[kw]; var density = ((count / totalWords) * 100).toFixed(2); topKeywordsHtml += ''; } topKeywordsHtml += '
' + kw + '' + count + ' appearances (' + density + '%)
'; keywordListEl.innerHTML = topKeywordsHtml; resultsDiv.style.display = 'block'; }

Leave a Comment