Digi Speed SEO Tool

Free Heading Analyzer for Better SEO

Analyze your website headings, check H1–H6 structure, find hierarchy issues and improve your on-page SEO with Digi Speed Heading Analyzer.

H

Heading Analyzer

Paste your HTML content below to analyze heading structure.

`;analyze();});analyzeBtn.addEventListener("click", analyze);function analyze() {const html = input.value.trim();if (!html) { alert("Please paste your HTML content first."); input.focus(); return; }const parser = new DOMParser(); const doc = parser.parseFromString(html, "text/html");const headings = Array.from( doc.querySelectorAll("h1, h2, h3, h4, h5, h6") );const h1 = headings.filter(h => h.tagName === "H1"); const h2 = headings.filter(h => h.tagName === "H2");totalEl.textContent = headings.length; h1El.textContent = h1.length; h2El.textContent = h2.length; otherEl.textContent = Math.max(0, headings.length - h1.length - h2.length);renderHeadingList(headings);const analysis = analyzeStructure(headings, h1);renderChecks(analysis);scoreEl.textContent = analysis.score; scoreTextEl.textContent = getScoreText(analysis.score);results.classList.add("active");results.scrollIntoView({ behavior: "smooth", block: "start" }); }function analyzeStructure(headings, h1) {let score = 100; const checks = [];/* H1 */ if (h1.length === 0) {score -= 25;checks.push({ type: "bad", title: "No H1 heading found", text: "Consider adding a clear primary H1 that describes the main topic." });} else if (h1.length === 1) {checks.push({ type: "good", title: "One H1 heading detected", text: "A clear primary H1 is present in the content." });} else {score -= 15;checks.push({ type: "warn", title: h1.length + " H1 headings detected", text: "Review whether multiple H1 elements are intentional and useful." }); }/* Total headings */ if (headings.length === 0) {score -= 30;checks.push({ type: "bad", title: "No headings detected", text: "Your content does not contain H1–H6 heading elements." });} else {checks.push({ type: "good", title: "Heading elements detected", text: headings.length + " heading elements were found." }); }/* Hierarchy */ let skipped = [];for (let i = 1; i < headings.length; i++) {const previous = parseInt( headings[i - 1].tagName.substring(1) );const current = parseInt( headings[i].tagName.substring(1) );if (current > previous + 1) { skipped.push( headings[i - 1].tagName + " → " + headings[i].tagName ); } }if (skipped.length > 0) {score -= Math.min(20, skipped.length * 7);checks.push({ type: "warn", title: "Heading level skips detected", text: "Potential hierarchy jumps: " + skipped.join(", ") });} else if (headings.length > 1) {checks.push({ type: "good", title: "Heading hierarchy looks consistent", text: "No obvious heading level skips were detected." }); }/* Long heading check */ const longHeadings = headings.filter( h => h.textContent.trim().length > 120 );if (longHeadings.length > 0) {score -= 5;checks.push({ type: "warn", title: "Long headings found", text: longHeadings.length + " heading(s) contain more than 120 characters." });} else if (headings.length > 0) {checks.push({ type: "good", title: "Heading length looks reasonable", text: "No unusually long heading was detected." }); }score = Math.max(0, Math.min(100, score));return { score, checks }; }function renderChecks(analysis) {checksEl.innerHTML = "";analysis.checks.forEach(function (item) {const div = document.createElement("div");div.className = "dgs-ha-check " + item.type;const icon = item.type === "good" ? "✓" : item.type === "bad" ? "!" : "•";div.innerHTML = `
${icon}
${escapeHTML(item.title)} ${escapeHTML(item.text)}
`;checksEl.appendChild(div);}); }function renderHeadingList(headings) {listEl.innerHTML = "";if (!headings.length) {listEl.innerHTML = '
No headings found.
';return; }headings.forEach(function (heading) {const item = document.createElement("div");item.className = "dgs-ha-heading-item";item.innerHTML = ` ${heading.tagName} ${escapeHTML( heading.textContent.trim() || "(Empty heading)" )} `;listEl.appendChild(item); }); }function getScoreText(score) {if (score >= 90) { return "Your heading structure looks well organized."; }if (score >= 75) { return "Your heading structure is generally good, with some areas to review."; }if (score >= 50) { return "Several heading structure improvements may be useful."; }return "Your heading structure needs significant attention."; }function escapeHTML(value) {return String(value) .replace(/&/g, "&") .replace(//g, ">") .replace(/"/g, """) .replace(/'/g, "'"); }/* FAQ */document.querySelectorAll(".dgs-ha-faq-question") .forEach(function (button) {button.addEventListener("click", function () {const item = button.closest(".dgs-ha-faq-item");document.querySelectorAll(".dgs-ha-faq-item") .forEach(function (other) {if (other !== item) { other.classList.remove("active"); }});item.classList.toggle("active");});});/* WhatsApp Form */const whatsappForm = document.getElementById("dgsHaWhatsappForm");whatsappForm.addEventListener("submit", function (event) {event.preventDefault();const name = document.getElementById("dgsHaName").value.trim();const phone = document.getElementById("dgsHaPhone").value.trim();const message = document.getElementById("dgsHaMessage").value.trim();const whatsappMessage = "Hello Digi Speed,%0A%0A" + "Name: " + encodeURIComponent(name) + "%0A" + "Phone: " + encodeURIComponent(phone || "Not provided") + "%0A%0A" + "Requirement:%0A" + encodeURIComponent(message);window.open( "https://wa.me/918808065856?text=" + whatsappMessage, "_blank" );});})();