FAQ Schema Generator (SEO Tool)
Add your questions and answers below to generate valid JSON-LD FAQ Schema for Google Rich Snippets.
Generated Schema:
' +
'' +
" +
'
' +
'' +
'' +
'' +
'
' +
'';
div.innerHTML = html;
container.appendChild(div);
};
var generateSchema = function() {
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,
"acceptedAnswer": {
"@type": "Answer",
"text": answers[i].value
}
});
}
}
var schema = {
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": mainEntity
};
var outputArea = document.getElementById('output-area');
var schemaCode = document.getElementById('schema-code');
schemaCode.textContent = '\n' + JSON.stringify(schema, null, 2) + '\n';
outputArea.style.display = 'block';
};
var copyToClipboard = function() {
var code = document.getElementById('schema-code').textContent;
var textArea = document.createElement("textarea");
textArea.value = code;
document.body.appendChild(textArea);
textArea.select();
document.execCommand("Copy");
document.body.removeChild(textArea);
alert("Schema copied to clipboard!");
};