# Keyword Density Checker: words, phrases and target keywords (`examsens.ai/keyword-density`) Actor

Counts word and phrase frequency and density on many web pages or texts, with stop word handling in 69 languages, and checks target keywords for count, density, stuffing and placement in the title, meta description, headings, first 100 words, URL and image alt text.

- **URL**: https://apify.com/examsens.ai/keyword-density.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** SEO tools, Marketing
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.90 / 1,000 page analyzeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Keyword Density Checker: words, phrases and target keywords

Check how often words and phrases appear on your pages, and whether your target keywords sit where they should. Give it page URLs or pasted drafts and get, for each one, the top words and 2 and 3 word phrases with counts and density, plus a placement check for every target keyword.

### For each page or text

- `wordCount` (every word, stop words included), `uniqueWords`, `contentWordCount` (without stop words)
- `words`, `twoWordPhrases`, `threeWordPhrases`: each with `term`, `count` and `density`, most frequent first
- `targets`: for each target keyword, `count`, `density`, a `status` (missing, low, ok or high), and for pages whether it appears in the title, the meta description, the H1, the other headings, the first 100 words, the URL and image alt text
- For pages: `title`, `metaDescription`, `h1`, `htmlLang`, `finalUrl` after redirects, and `language` (the stop word list used)

Density is the share of all words a term takes up: count × words in the term ÷ total words × 100. A two word phrase found 5 times in 500 words has a density of 2%.

A target keyword is marked high above 3% (a sign of keyword stuffing), low below 0.5%, and missing when absent. Both limits can be changed.

Phrases never run across a full stop, comma or other punctuation, and with stop words left out they never start or end with one: "running shoes" is counted, "the running" is not. Matching ignores case.

### Input

- Page URLs and texts
- Target keywords: words or phrases to check
- Page text: main content (default; menus, footers, sidebars and cookie notices left out) or all visible text
- Count title and meta description (default on)
- Leave out stop words (default on), stop word language (auto by default, 69 languages), extra stop words such as a brand name
- Longest phrase (1 to 3 words), rows per list (default 30), fewest occurrences (default 2), shortest word (default 3 letters)
- Low and high density limits for target keywords

### Output

Dataset: one item per page or text. A page that cannot be analyzed gets `ok: false` and an `error`, such as `HTTP 404` or `not an HTML page` for an image link. The other pages still run.

### Pricing

Pay per event: one event per page or text analyzed. A page that fails is not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Each page is downloaded once, without a browser, so text the site's JavaScript adds after loading is not counted. Nothing is stored beyond the run's own storage.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

## `urls` (type: `array`):

Web pages to analyze. Up to 10 MB each.

## `texts` (type: `array`):

Drafts or other text to analyze, one per entry.

## `targetKeywords` (type: `array`):

Words or phrases to check on every page: count, density, and whether each appears in the title, meta description, H1, other headings, the first 100 words, the URL and image alt text.

## `contentScope` (type: `string`):

Main content leaves out menus, footers, sidebars and cookie notices. All visible text counts everything on the page.

## `includeTitleAndMeta` (type: `boolean`):

Add the page title and meta description to the counted text.

## `excludeStopwords` (type: `boolean`):

Leave common words such as the, and, of out of the word list, and out of the start and end of phrases. They still count toward the total word count.

## `language` (type: `string`):

ISO 639-1 code such as en, de or fr. Auto picks the list that matches the text best.

## `extraStopwords` (type: `array`):

More words to leave out, such as your brand name.

## `maxPhraseWords` (type: `integer`):

1 lists words only; 2 adds two word phrases; 3 adds three word phrases.

## `topN` (type: `integer`):

How many words and phrases to list in each of the word, two word and three word lists.

## `minFrequency` (type: `integer`):

List only words and phrases that appear at least this many times.

## `minWordLength` (type: `integer`):

Leave out shorter words.

## `minDensity` (type: `string`):

A target keyword below this density is marked low.

## `maxDensity` (type: `string`):

A target keyword above this density is marked high, a sign of keyword stuffing.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.python.org/about/"
    }
  ],
  "targetKeywords": [
    "python",
    "programming language"
  ],
  "contentScope": "main",
  "includeTitleAndMeta": true,
  "excludeStopwords": true,
  "language": "auto",
  "maxPhraseWords": 3,
  "topN": 30,
  "minFrequency": 2,
  "minWordLength": 3,
  "minDensity": "0.5",
  "maxDensity": "3"
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        {
            "url": "https://www.python.org/about/"
        }
    ],
    "targetKeywords": [
        "python",
        "programming language"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/keyword-density").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "urls": [{ "url": "https://www.python.org/about/" }],
    "targetKeywords": [
        "python",
        "programming language",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/keyword-density").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    {
      "url": "https://www.python.org/about/"
    }
  ],
  "targetKeywords": [
    "python",
    "programming language"
  ]
}' |
apify call examsens.ai/keyword-density --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,examsens.ai/keyword-density"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/eg819wT4dlbMmgazZ/builds/EFjG9xce07hK5c4Js/openapi.json
