Keyword Density

TL;DR

Keyword density refers to the number (as a %) of the same keyword within a given piece of content with a specific number of words. 
To calculate the ratio of the keywords, use the formula: 
(The total number of times the keyword  is used in your content/Total number of words of analyzed content) * 100. 

What is keyword density?

Keyword density, referred to as keyword frequency as well, represents the frequency (percentage) of a keyword within a piece of content. To calculate the keyword density of a page or an article, divide the number of times a specific keyword is mentioned by the total number of words on the page.

Keyword density formula

(The total number of times the keyword is used in your content/Total number of words of analyzed content) * 100. 

Note: When calculating keyword density, ignore HTML tags and other embedded tags that will not be displayed on the page when the content is published.

Example:
If your content has 500 words and the same keyword is used 10 times, then the keyword density is 
(10/500)*100 = 2%. 

What is the optimum keyword density?

Currently, there is no accurate way to know how many keywords a page is allowed to have in order to avoid keyword stuffing and to get a proper keyword density and high ranking in search engine results. 
On the other hand, keyword density depends on the content, context, and time as well; a viral article in the news about something that was just released by a well-established company may need significantly fewer keywords to rank highly than an older evergreen blog post.

However, some unofficial guidelines recommend a limit of 1 keyword per 200 words of content in order to be indexed and to avoid penalties from search engines.

up-arrow.svg