FAQ Schema Generator
Add your questions and answers to generate Google-ready JSON-LD structured data.
JSON-LD Output:
' +
'' +
" +
'
' +
'' +
'' +
'' +
'
';
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);
}