Keyword density is the measurement in percentage, the number of times a keyword or phrase appears compared to the total number of words in a page. In the context of search engine optimization keyword density can be used as a factor in determining whether a web page is relevant to a specified keyword or keyword phrase. Due to the ease of managing keyword density, search engines usually implement other measures of relevancy to prevent unscrupulous webmasters from creating search spam through practices such as keyword stuffing.

The formula to calculate your keyword density on a webpage for SEO purposes is :

(Nkr / Tkn) * 100

Where Nkr is how many times you repetead a specific keyword and
Tkn the total words in the analyzed text.

This will result in a keyword density value.