Keyword Density Analyzer

Author: alxgntv · Created: October 17, 2026 · Last updated: October 17, 2026 · Version 1.0.0

Keyword Density Analyzer is a single-page tool that shows how often each word and phrase appears in a text, the density of target keywords, and basic text statistics. It runs fully in the browser: no server, no account, no API key, and the text is never sent anywhere.

Requirements

Installation

  1. Unzip the archive.
  2. Upload the keyword-density-analyzer folder to your host, for example to https://example.com/keyword-density/. On Cloudflare Pages, Netlify, or Vercel, use the folder as the publish directory; there is no build command.
  3. Open the address in a browser. The tool is ready.

The page must be opened through a web server. Opening index.html straight from the disk (a file:// address) does not load ES modules in most browsers. To try it on your computer:

cd keyword-density-analyzer
python3 -m http.server 8080
# open http://localhost:8080

Configuration

There are no settings files and no keys. Everything you may want to change:

WhatWhere
Title, intro text, and labelsindex.html
Colors, fonts, light and dark themethe variables at the top of css/style.css (every class starts with kda-)
Good density range (1–3%)DENSITY_RANGE in js/keyword-density.js; update the hint in index.html to match
Number of phrases per list (20)the limit option passed to analyzeText in js/app.js
Stop wordsjs/stop-words.js
Example text and keywordsEXAMPLE_TEXT and EXAMPLE_KEYWORDS in js/app.js
Iconimg/icon.svg

The page has a strict Content-Security-Policy in index.html (connect-src 'none', only files from the same site). If you add analytics or fonts from another domain, add that domain to the policy.

Embedding the tool in another page

Put the page in an iframe: <iframe src="/keyword-density/" title="Keyword Density Analyzer" style="width:100%;height:1400px;border:0"></iframe>. Or copy the markup inside <main class="kda"> into your page and load css/style.css and js/app.js (as type="module").

How to use

  1. Paste your text, a Markdown draft, or the HTML of a page into Text to analyze. Press Try an example to see a sample.
  2. Optionally type your Target keywords, separated by commas.
  3. Read the results; they update as you type:
    • The statistics: words, unique words, sentences, characters, characters without spaces, reading time.
    • Target keywords: count, density, and a level: Missing, Too low (under 1%), Good (1–3%), Too high (over 3%).
    • The top phrases of 1 word, 2 words, and 3 words. Switch tabs with a click or the arrow keys.
  4. Options: Hide stop words (on by default) removes words such as "the" and "of" from the lists; Count plurals (on by default) counts "tool" and "tools" as the same keyword; Format forces text, Markdown, or HTML when the detection guesses wrong.
  5. Press Download CSV to save the results for a spreadsheet, or Copy results to paste them into a message or a document.

Screenshots

The analyzer with an example text: statistics, target keywords, and the top words

Two-word phrases tab and the export buttons

The analyzer in dark mode The analyzer on a phone

How it counts

Using the module in your code

js/keyword-density.js has no DOM and no network code. It works in browsers and in Node.js.

import { analyzeText, toCsv } from './js/keyword-density.js';

const result = analyzeText('<h1>SEO tips</h1><p>Best SEO tips for writers.</p>', {
  format: 'auto',          // 'auto' | 'text' | 'markdown' | 'html'
  keywords: 'seo tips',    // a string separated by commas or new lines, or an array
  ignoreStopWords: true,
  includePlurals: true,
  limit: 20,
});

result.stats;        // { words, uniqueWords, characters, charactersNoSpaces, sentences, readingMinutes }
result.phrases[2];   // [{ phrase: 'seo tips', count: 2, density: 28.57 }]
result.keywords;     // [{ keyword: 'seo tips', count: 2, density: 28.57, level: 'high' }]
toCsv(result);       // CSV text

Other exports: extractText, tokenize, detectFormat, parseKeywords, pluralForms, densityLevel, toPlainText, DENSITY_RANGE. Each has a JSDoc comment.

Tests: node --test keyword-density-analyzer/tests/keyword-density.test.mjs from the folder that holds keyword-density-analyzer.

Files

FileWhat it is
index.htmlThe page
css/style.cssStyles, light and dark
js/keyword-density.jsThe analysis module
js/stop-words.jsEnglish stop words
js/app.jsConnects the page to the module
img/icon.svgIcon
robots.txtLets search engines index the page
tests/keyword-density.test.mjsUnit tests

Changelog

Sources and credits

No third-party libraries, frameworks, fonts, or images are used. The page uses the fonts already on the visitor's device. The icon was drawn for this product. The reading speed of 238 words per minute is the average adult silent reading rate from Brysbaert, M. (2019), "How many words do we read per minute? A review and meta-analysis of reading rate", Journal of Memory and Language.