Calculator Food Cost

FAQ Schema Generator

Add your questions and answers to generate Google-ready JSON-LD structured data.

JSON-LD Output:

var faqCount = 1; function addFaqField() { var container = document.getElementById('faq-container'); var div = document.createElement('div'); div.className = 'faq-item'; div.style.cssText = 'margin-bottom: 15px; padding: 15px; background: #f8f9fa; border-radius: 5px; border-left: 4px solid #1a73e8; position: relative;'; div.innerHTML = '' + '
' + '' + " + '
' + '
' + '' + '' + '
'; container.appendChild(div); } function generateSchema() { var questions = document.getElementsByClassName('faq-q'); var answers = document.getElementsByClassName('faq-a'); var schema = { "@context": "https://schema.org", "@type": "FAQPage", "mainEntity": [] }; for (var i = 0; i < questions.length; i++) { if (questions[i].value.trim() !== "" && answers[i].value.trim() !== "") { schema.mainEntity.push({ "@type": "Question", "name": questions[i].value, "acceptedAnswer": { "@type": "Answer", "text": answers[i].value } }); } } var outputArea = document.getElementById('result-area'); var outputBox = document.getElementById('schema-output'); outputBox.value = '\n' + JSON.stringify(schema, null, 2) + '\n'; outputArea.style.display = 'block'; } function copyToClipboard() { var copyText = document.getElementById("schema-output"); copyText.select(); copyText.setSelectionRange(0, 99999); document.execCommand("copy"); var btn = document.getElementById("copy-btn"); var originalText = btn.innerText; btn.innerText = "Copied!"; btn.style.background = "#34a853"; setTimeout(function() { btn.innerText = originalText; btn.style.background = "#5f6368"; }, 2000); }

Leave a Comment