Keyword Clustering Tool

Keyword Clustering Tool

Automatically group your keyword list into relevant, themed clusters.

Your clustered keywords will appear here...

No clusters could be formed. Try a different set of keywords.

'; pdfButtonContainer.classList.add('hidden'); return; } const colors = ['#3b82f6', '#10b981', '#f97316', '#8b5cf6', '#ef4444', '#14b8a6']; let colorIndex = 0; let totalKeywords = 0; clusters.forEach(cluster => { totalKeywords += cluster.keywords.length; const card = document.createElement('div'); card.className = 'cluster-card p-4 rounded-lg mb-4'; card.style.borderLeftColor = colors[colorIndex % colors.length]; colorIndex++; const rootTerm = cluster.root.split(' ').filter(word => !STOP_WORDS.has(word)).join(' '); let keywordsHTML = cluster.keywords.map(kw => `
  • ${kw}
  • `).join(''); card.innerHTML = `

    ${rootTerm} (${cluster.keywords.length} keywords)

      ${keywordsHTML}
    `; clustersOutput.appendChild(card); }); clusterSummary.textContent = `${clusters.length} clusters found with a total of ${totalKeywords} keywords.`; pdfButtonContainer.classList.remove('hidden'); }; const handlePdfDownload = () => { if (!lastClusters) return; const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const margin = 50; const pageWidth = pdf.internal.pageSize.getWidth(); let yPos = margin; pdf.setFontSize(24); pdf.setFont('Helvetica', 'bold'); pdf.text("Keyword Clustering Report", pageWidth / 2, yPos, { align: 'center' }); yPos += 40; lastClusters.forEach(cluster => { const rootTerm = cluster.root.split(' ').filter(word => !STOP_WORDS.has(word)).join(' '); const title = `${rootTerm} (${cluster.keywords.length} keywords)`; if (yPos > pdf.internal.pageSize.getHeight() - 80) { pdf.addPage(); yPos = margin; } pdf.setFontSize(16); pdf.setFont('Helvetica', 'bold'); pdf.text(title, margin, yPos); yPos += 25; pdf.setFontSize(10); pdf.setFont('Helvetica', 'normal'); cluster.keywords.forEach(kw => { if (yPos > pdf.internal.pageSize.getHeight() - 40) { pdf.addPage(); yPos = margin; } pdf.text(`• ${kw}`, margin + 10, yPos); yPos += 15; }); yPos += 20; }); const today = new Date().toLocaleDateString('en-US'); const pageCount = pdf.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { pdf.setPage(i); const pageHeight = pdf.internal.pageSize.getHeight(); pdf.setFontSize(9); pdf.setTextColor(150); pdf.text(`Generated on ${today}`, margin, pageHeight - 30); pdf.text(`Page ${i} of ${pageCount}`, pageWidth - margin, pageHeight - 30, { align: 'right' }); } pdf.save('keyword-clusters.pdf'); }; generateBtn.addEventListener('click', generateClusters); downloadPdfBtn.addEventListener('click', handlePdfDownload); // Sample Data (USA relevant) keywordsInput.value = `electric cars for sale buy used electric cars best electric cars 2025 tesla model 3 review ford mustang mach-e price honda accord reliability used honda accord for sale best family sedans 2025 honda accord review`; // Initial generation on load generateClusters(); });
    Scroll to Top