{"id":1602,"date":"2024-12-08T15:58:54","date_gmt":"2024-12-08T15:58:54","guid":{"rendered":"https:\/\/donhit.com\/en\/?p=1602"},"modified":"2025-02-06T01:43:52","modified_gmt":"2025-02-06T01:43:52","slug":"keyword-density-analyzer","status":"publish","type":"post","link":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/","title":{"rendered":"Keyword Density Analyzer"},"content":{"rendered":"<p><center><div class=\"container123\">\r\n        <div class=\"header123\">\r\n            <h2>Keyword Density Analyzer<\/h2>\r\n            <p>Analyze the frequency and density of keywords in your text<\/p>\r\n        <\/div>\r\n        \r\n        <div class=\"input-section\">\r\n            <textarea \r\n                id=\"textInput\" \r\n                placeholder=\"Paste your text here to analyze keyword density...\"\r\n            ><\/textarea>\r\n            \r\n            <button id=\"analyzeBtn\" class=\"btn\">\r\n                <i class=\"fas fa-chart-bar\"><\/i> Analyze Keywords\r\n            <\/button>\r\n        <\/div>\r\n        \r\n        <div id=\"resultsSection\" class=\"results-section\" style=\"display:none;\">\r\n            <div class=\"stats-container\">\r\n                <div class=\"stat-box\">\r\n                    <h3>Total Words<\/h3>\r\n                    <h2 id=\"totalWordCount\">0<\/h2>\r\n                <\/div>\r\n                <div class=\"stat-box\">\r\n                    <h3>Unique Keywords<\/h3>\r\n                    <h2 id=\"uniqueKeywordCount\">0<\/h2>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <div id=\"keywordDensityChart\"><\/div>\r\n\r\n            <table id=\"keywordTable\" class=\"keyword-table\">\r\n                <thead>\r\n                    <tr>\r\n                        <th>Keyword<\/th>\r\n                        <th>Count<\/th>\r\n                        <th>Density (%)<\/th>\r\n                        <th>Visualization<\/th>\r\n                    <\/tr>\r\n                <\/thead>\r\n                <tbody id=\"keywordTableBody\"><\/tbody>\r\n            <\/table>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <script>\r\n        const textInput = document.getElementById('textInput');\r\n        const analyzeBtn = document.getElementById('analyzeBtn');\r\n        const resultsSection = document.getElementById('resultsSection');\r\n        const totalWordCountEl = document.getElementById('totalWordCount');\r\n        const uniqueKeywordCountEl = document.getElementById('uniqueKeywordCount');\r\n        const keywordTableBody = document.getElementById('keywordTableBody');\r\n\r\n        function sanitizeText(text) {\r\n            \/\/ Remove punctuation and convert to lowercase\r\n            return text.toLowerCase().replace(\/[^\\w\\s]\/g, '');\r\n        }\r\n\r\n        function calculateKeywordDensity(text) {\r\n            \/\/ Sanitize and split text into words\r\n            const words = sanitizeText(text).split(\/\\s+\/);\r\n            const totalWordCount = words.length;\r\n\r\n            \/\/ Count word frequencies\r\n            const wordFrequency = words.reduce((acc, word) => {\r\n                \/\/ Ignore very short words\r\n                if (word.length > 2) {\r\n                    acc[word] = (acc[word] || 0) + 1;\r\n                }\r\n                return acc;\r\n            }, {});\r\n\r\n            \/\/ Sort keywords by frequency\r\n            const sortedKeywords = Object.entries(wordFrequency)\r\n                .sort((a, b) => b[1] - a[1])\r\n                .slice(0, 20); \/\/ Top 20 keywords\r\n\r\n            \/\/ Calculate keyword density\r\n            const keywordDensityData = sortedKeywords.map(([keyword, count]) => {\r\n                const density = ((count \/ totalWordCount) * 100).toFixed(2);\r\n                return { keyword, count, density };\r\n            });\r\n\r\n            return {\r\n                totalWordCount,\r\n                uniqueKeywordCount: Object.keys(wordFrequency).length,\r\n                keywordDensityData\r\n            };\r\n        }\r\n\r\n        function renderKeywordTable(data) {\r\n            keywordTableBody.innerHTML = data.map(item => `\r\n                <tr>\r\n                    <td>${item.keyword}<\/td>\r\n                    <td>${item.count}<\/td>\r\n                    <td>${item.density}%<\/td>\r\n                    <td>\r\n                        <div class=\"progress-bar\">\r\n                            <div class=\"progress-bar-fill\" \r\n                                 style=\"width: ${Math.min(item.density * 3, 100)}%\">\r\n                            <\/div>\r\n                        <\/div>\r\n                    <\/td>\r\n                <\/tr>\r\n            `).join('');\r\n        }\r\n\r\n        analyzeBtn.addEventListener('click', () => {\r\n            const text = textInput.value;\r\n            if (!text.trim()) {\r\n                alert('Please enter some text to analyze.');\r\n                return;\r\n            }\r\n\r\n            const results = calculateKeywordDensity(text);\r\n\r\n            \/\/ Update total word and unique keyword counts\r\n            totalWordCountEl.textContent = results.totalWordCount;\r\n            uniqueKeywordCountEl.textContent = results.uniqueKeywordCount;\r\n\r\n            \/\/ Render keyword table\r\n            renderKeywordTable(results.keywordDensityData);\r\n\r\n            \/\/ Show results section\r\n            resultsSection.style.display = 'block';\r\n        });\r\n    <\/script><\/center><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[187],"tags":[],"class_list":["post-1602","post","type-post","status-publish","format-standard","hentry","category-tools"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Keyword Density Analyzer - DonHit<\/title>\n<meta name=\"description\" content=\"Keyword density is a measure of how frequently a keyword or phrase appears within a piece of content, expressed as a percentage of the total word count.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Keyword Density Analyzer - DonHit\" \/>\n<meta property=\"og:description\" content=\"Keyword density is a measure of how frequently a keyword or phrase appears within a piece of content, expressed as a percentage of the total word count.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/\" \/>\n<meta property=\"og:site_name\" content=\"DonHit - World of Tools\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-08T15:58:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-02-06T01:43:52+00:00\" \/>\n<meta name=\"author\" content=\"DonHit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DonHit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Keyword Density Analyzer - DonHit","description":"Keyword density is a measure of how frequently a keyword or phrase appears within a piece of content, expressed as a percentage of the total word count.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/","og_locale":"en_US","og_type":"article","og_title":"Keyword Density Analyzer - DonHit","og_description":"Keyword density is a measure of how frequently a keyword or phrase appears within a piece of content, expressed as a percentage of the total word count.","og_url":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/","og_site_name":"DonHit - World of Tools","article_published_time":"2024-12-08T15:58:54+00:00","article_modified_time":"2025-02-06T01:43:52+00:00","author":"DonHit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DonHit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/#article","isPartOf":{"@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/"},"author":{"name":"DonHit","@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"headline":"Keyword Density Analyzer","datePublished":"2024-12-08T15:58:54+00:00","dateModified":"2025-02-06T01:43:52+00:00","mainEntityOfPage":{"@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/"},"wordCount":8,"commentCount":0,"publisher":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"articleSection":["Tools"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/","url":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/","name":"Keyword Density Analyzer - DonHit","isPartOf":{"@id":"https:\/\/donhit.com\/en\/#website"},"datePublished":"2024-12-08T15:58:54+00:00","dateModified":"2025-02-06T01:43:52+00:00","description":"Keyword density is a measure of how frequently a keyword or phrase appears within a piece of content, expressed as a percentage of the total word count.","breadcrumb":{"@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/donhit.com\/en\/tools\/keyword-density-analyzer\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Trang ch\u1ee7","item":"https:\/\/donhit.com\/en\/"},{"@type":"ListItem","position":2,"name":"Tools","item":"https:\/\/donhit.com\/en\/category\/tools\/"},{"@type":"ListItem","position":3,"name":"Keyword Density Analyzer"}]},{"@type":"WebSite","@id":"https:\/\/donhit.com\/en\/#website","url":"https:\/\/donhit.com\/en\/","name":"DonHit - World of tools","description":"","publisher":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/donhit.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/0c6ff7dcd8ba4810c56a532f09c33148","name":"DonHit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/donhit.com\/en\/wp-content\/uploads\/2024\/11\/logo-donhit.webp","contentUrl":"https:\/\/donhit.com\/en\/wp-content\/uploads\/2024\/11\/logo-donhit.webp","width":400,"height":267,"caption":"DonHit"},"logo":{"@id":"https:\/\/donhit.com\/en\/#\/schema\/person\/image\/"},"description":"DonHit is a website designed to provide useful tools for everyone. Its primary goal is to support and empower the community. All the tools available on the site are completely free to use.","sameAs":["https:\/\/donhit.com\/en"],"url":"https:\/\/donhit.com\/en\/author\/admin_don\/"}]}},"_links":{"self":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/comments?post=1602"}],"version-history":[{"count":3,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1602\/revisions"}],"predecessor-version":[{"id":2042,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/posts\/1602\/revisions\/2042"}],"wp:attachment":[{"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/media?parent=1602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/categories?post=1602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/donhit.com\/en\/wp-json\/wp\/v2\/tags?post=1602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}