← Back to all products

Keyword Density Checker

$19

Analyze keyword density, frequency, and distribution across web page content.

📁 9 files
MarkdownPython

📄 Product Preview

Try the interactive reader and demo tools below, or get the full product with all content unlocked.

📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample

📁 File Structure 9 files

keyword-density-checker/ ├── LICENSE ├── README.md ├── examples/ │ └── sample_article.txt ├── free-sample.zip ├── guide/ │ ├── 01_features.md │ ├── 02_density-status-labels.md │ └── 03_license.md ├── index.html └── src/ └── keyword_density_checker.py

📖 Documentation Preview README excerpt

Keyword Density Checker

Part of the SEO Toolkit by CodeVault

Analyze text or HTML content for keyword density, n-gram frequency, readability scores, and content optimization signals.

Features

  • Keyword density calculation with status labels (optimal, low, high, stuffed)
  • N-gram analysis: top unigrams, bigrams, and trigrams
  • Flesch-Kincaid readability scoring (Reading Ease + Grade Level)
  • HTML text extraction (strips scripts, styles, tags)
  • Stop word filtering for cleaner n-gram results
  • Vocabulary richness metric
  • Content length warnings for SEO
  • Text and JSON output formats
  • Python stdlib only — zero dependencies

Quick Start


# Analyze a text file
python src/keyword_density_checker.py --input examples/sample_article.txt

# Check specific keyword densities
python src/keyword_density_checker.py --input article.txt --keywords "seo,keyword density,python"

# Analyze HTML content
python src/keyword_density_checker.py --input page.html --keywords "seo tools"

# JSON output
python src/keyword_density_checker.py --input article.txt --format json --output report.json

Density Status Labels

StatusDensity RangeMeaning
absent0%Keyword not found
low< 0.5%Might need more mentions
optimal0.5% - 2.5%Sweet spot
high2.5% - 3.0%Getting aggressive
stuffed> 3.0%Risk of penalty

CLI Flags

FlagDescription
--input, -iInput file path (required)
--keywords, -kComma-separated target keywords
--htmlForce HTML parsing mode
--format, -fOutput: text or json
--output, -oOutput file (default: stdout)

License

MIT — See LICENSE file.

📄 Code Sample .py preview

src/keyword_density_checker.py #!/usr/bin/env python3 """ Keyword Density Checker — SEO Toolkit by DataNest Analyze text or HTML content for keyword density, n-gram frequency, readability scores (Flesch-Kincaid), and content optimization signals. Why this exists: Keyword stuffing kills rankings, but too-low density means you're not signaling relevance. This tool gives you the exact numbers — density percentages, n-gram distributions, and readability scores — so you can optimize content with data, not guesswork. Usage: python keyword_density_checker.py --input article.html python keyword_density_checker.py --input article.txt --keywords "python,seo,tools" python keyword_density_checker.py --input article.html --format json --output report.json License: MIT """ from __future__ import annotations import argparse import json import logging import math import re import sys from collections import Counter from dataclasses import dataclass, field, asdict from html.parser import HTMLParser from pathlib import Path from typing import Any # --------------------------------------------------------------------------- # Constants # --------------------------------------------------------------------------- LOG = logging.getLogger("keyword-density-checker") # Recommended keyword density range (percentage) DENSITY_MIN_OPTIMAL = 0.5 DENSITY_MAX_OPTIMAL = 2.5 DENSITY_MAX_WARNING = 3.0 # Common English stop words (for filtering n-grams) STOP_WORDS = frozenset({ "a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any", "are", "as", "at", "be", "because", "been", "before", # ... 470 more lines ...
Buy Now — $19 Back to Products