SEO FAQ Schema Generator
Add your questions and answers to generate valid JSON-LD schema for Google Rich Results.
' +
'' +
" +
'
' +
'' +
'' +
'' +
'
';
container.appendChild(div);
}
function generateSchema() {
var questions = document.getElementsByClassName('faq-q');
var answers = document.getElementsByClassName('faq-a');
var mainEntity = [];
for (var i = 0; i < questions.length; i++) {
if (questions[i].value.trim() !== '' && answers[i].value.trim() !== '') {
mainEntity.push({
"@type": "Question",
"name": questions[i].value.trim(),
"acceptedAnswer": {
"@type": "Answer",
"text": answers[i].value.trim()
}
});
}
}
var schema = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": mainEntity
};
var outputArea = document.getElementById('schema-output');
outputArea.value = '\n' + JSON.stringify(schema, null, 2) + '\n';
document.getElementById('output-section').style.display = 'block';
}
function copyToClipboard() {
var copyText = document.getElementById("schema-output");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
alert("Schema copied to clipboard!");
}