What does keyword density measure?

A density calculation compares counted occurrences with the counted words in the same text sample. Choose the text boundary and counting method first. Exact-phrase matching, stemming, punctuation handling and whether navigation is included can all change the result.

Declare the numerator and denominator

For this example, count non-overlapping occurrences of an exact phrase in the article body and divide by the body word count. Multiply that ratio by 100 to express it as a percentage. Count an entire phrase as one occurrence and keep that convention with the result.

A phrase-occurrence ratio and the share of word tokens occupied by that phrase are different measures. A phrase with several words occupies several tokens per occurrence, so label the method rather than treating outputs from different counters as interchangeable.

A hypothetical calculation

Suppose a hypothetical article contains 1,000 counted words and 12 non-overlapping occurrences of the chosen phrase. These are invented inputs for explaining arithmetic, not a recommended frequency or a measured webpage.

Under the declared phrase-occurrence convention, the result is 1.2%. The arithmetic does not classify the article as good, bad, safe or spam.

function densityPercent(occurrences, words) {
  if (!Number.isInteger(occurrences) || !Number.isInteger(words) ||
      occurrences < 0 || words <= 0 || occurrences > words) {
    throw new RangeError("Use valid counts from the same text sample.");
  }
  return (occurrences / words) * 100;
}
console.log(densityPercent(12, 1000));

Frequency and corpus weighting answer different questions

TF-IDF weights text features using document and corpus information rather than reporting a simple within-page percentage. Google’s text-classification guide discusses TF-IDF as a machine-learning vectorization method. That documentation does not identify a required keyword density or establish TF-IDF as a Google Search ranking formula. Google text-classification guide.

Google defines keyword stuffing as filling a webpage with keywords or numbers to manipulate search rankings, often unnaturally or out of context. The policy gives examples such as low-value lists and unnatural repetition; it does not state a density threshold in that definition. Google spam policies.

Inspect the actual passages. A repeated technical term can help explain a subject, while a city list inserted without reader value calls for a different review. A counter can locate repetition; an editor still has to assess its purpose.

Edit for the reader’s question

Google’s starter guide says its language-matching systems can relate a page to many queries even when their exact terms are not explicitly used. It also warns against excessive repetition, including variations. Google SEO Starter Guide.

Read repeated passages together, remove redundant sentences and keep precise terms where they help understanding. Do not add filler merely to lower a percentage, or replace a correct technical term with a vague synonym.

Questions about keyword density

Does Google’s spam definition set an ideal density?

The cited keyword-stuffing definition does not provide a numeric target. It describes manipulative, unnatural or out-of-context use. A percentage alone is not a policy diagnosis.

Google spam policies.

Should a multiword phrase count as one occurrence?

It can under a phrase-occurrence convention. State that convention and the word-count method. Counting occupied word tokens instead will answer a different question.

What if the counted text is empty?

The denominator is zero, so this percentage is undefined. Report that the calculation is unavailable; do not display a zero density.

Keyword Stuffing · Keyword Research · Search Intent

Primary references