Keyword Density is the percentage of keywords have you used in your content or body text. You can check the keywords density through (Total Number of Keywords/Words Count in Content * 100). That was the formula of counting keyword density.
You can use 2-4% keywords on your on the page & off page content that was depends on your content length. Write long descriptive & informative content.