Schema Validation
Validate your structured data to catch errors before they affect how AI systems understand your content. Invalid schema can lead to missing or incorrect information in AI responses.
In this guide
- Schema validation tools and methods
- Common schema errors to avoid
- Testing in development workflows
- Automated validation integration
Why Validate Structured Data?
Invalid or malformed structured data can cause several problems:
Silent Failures
AI systems may ignore invalid schema entirely without warning you.
Incorrect Data
Malformed schema might be parsed incorrectly, leading to wrong information.
Missing Rich Results
Search engines and AI won't display enhanced results for invalid schema.
Validation Tools
Google Rich Results Test
The most practical tool for testing schema that powers search features:
search.google.com/test/rich-results- • Test by URL or paste code directly
- • Shows which rich results your schema enables
- • Highlights errors and warnings
- • Preview rendered results
Schema.org Validator
Official validator from Schema.org for strict compliance checking:
validator.schema.org- • Validates against full Schema.org specification
- • More comprehensive than Google's tool
- • Good for catching edge case issues
JSON-LD Playground
Debug JSON-LD structure and expansion:
json-ld.org/playground- • Visualize JSON-LD expansion
- • Check @context resolution
- • Debug complex nested structures
Common Schema Errors
Missing Required Properties
{
"@type": "Product"
// Missing required: name, offers
} Each schema type has required properties. Check documentation.
Invalid Property Values
{
"@type": "Product",
"name": "Widget",
"offers": {
"price": "twenty nine" // Should be number
}
} Properties expect specific data types.
Invalid JSON Syntax
{
"@type": "Product",
"name": "Widget", // Trailing comma
} JSON must be syntactically valid.
Wrong @context
{
"@context": "http://schema.org", // Use https
"@type": "Product"
} Use https://schema.org for the context.
Command-Line Validation
Validate schema in your development workflow:
# Install schema-dts for TypeScript validation
npm install schema-dts
# Use jq to validate JSON syntax
cat schema.json | jq .
# Extract and validate schema from HTML
curl -s https://yoursite.com | \
grep -o '<script type="application/ld+json">.*</script>' | \
sed 's/<[^>]*>//g' | jq . Automated Testing
Integrate schema validation into your CI/CD pipeline:
// Example: Jest test for schema validation
const { validateSchema } = require('./schema-validator');
describe('Structured Data', () => {
test('homepage has valid Organization schema', async () => {
const html = await fetch('http://localhost:3000/').then(r => r.text());
const schema = extractJsonLd(html);
expect(schema).toContainEqual(
expect.objectContaining({
'@type': 'Organization',
'name': expect.any(String),
'url': expect.any(String)
})
);
});
test('product pages have valid Product schema', async () => {
const html = await fetch('http://localhost:3000/products/crm').then(r => r.text());
const schema = extractJsonLd(html);
const product = schema.find(s => s['@type'] === 'Product');
expect(product).toBeDefined();
expect(product.name).toBeDefined();
expect(product.offers).toBeDefined();
});
}); Validation Checklist
Before Deploying Schema
- □ Valid JSON syntax (no trailing commas, proper quotes)
- □ Correct @context (https://schema.org)
- □ All required properties present
- □ Property values match expected types
- □ Passes Google Rich Results Test
- □ Schema content matches visible page content
- □ No deprecated properties
Key Takeaway
Validate before you deploy.
Invalid structured data is worse than no structured data. It can mislead AI systems or be ignored entirely. Use validation tools in development and automate checks in CI/CD.
Sources
- Schema.org Validator: Official validation tool for Schema.org structured data
- Google Rich Results Test: Test and validate rich snippets eligibility
- JSON-LD Playground: Debug and visualize JSON-LD structure