Sub topic 11
Checking your markup with validators
This chapter assumes you can write JSON-LD with @context, @type, and nested entities, and that you can embed it in a script element. You will learn what the two main validators check, how to read their output, and which problems they cannot detect.
Two validators, two questions
Two tools cover most checking, and they answer different questions.
| Tool | Question it answers | Typical use |
|---|---|---|
| Schema Markup Validator (validator.schema.org) | Is this valid JSON-LD that uses schema.org types and properties correctly? | Checking syntax and vocabulary for any consumer |
| Google's Rich Results Test | Does this page qualify for Google's rich result features? | Checking required and recommended properties for Google |
Markup can pass the first tool and fail the second. Google requires some properties that schema.org treats as optional. Markup can also pass the second tool while using properties that Google ignores. Use both.
Both tools accept either a public URL or pasted code. Pasting is useful before deployment. A URL test shows what the crawler actually receives, including markup that JavaScript adds to the page.
A validation workflow
Reading the results
The tools report three levels of findings.
- Errors mean the markup is broken or a required property is missing. Google will not show a rich result for an item with errors.
- Warnings mean a recommended property is missing. The item may still qualify, but with less detail.
- Syntax errors mean the JSON could not be parsed. Nothing else gets checked until you fix these.
The most common syntax errors are a trailing comma, a missing quote, and a stray character left by a template. A JSON linter or python -m json.tool finds these quickly.
A worked example
This markup is valid JSON, but it has three semantic problems.
{
"@context": "https://schema.org",
"@type": "product",
"name": "Stainless Steel Pour-Over Kettle",
"offers": {
"@type": "Offer",
"price": "$39.90",
"pricecurrency": "EUR"
}
}The validators report the following:
productis not a known type, because type names are case sensitive. UseProduct.pricecurrencyis not a known property, because property names are also case sensitive. UsepriceCurrency."$39.90"is a poor value forprice. The price should be a plain number in a string, with the currency inpriceCurrency.
The corrected version:
{
"@context": "https://schema.org",
"@type": "Product",
"name": "Stainless Steel Pour-Over Kettle",
"image": "https://example.com/images/kettle.jpg",
"offers": {
"@type": "Offer",
"price": "39.90",
"priceCurrency": "EUR",
"availability": "https://schema.org/InStock"
}
}The corrected version also adds image and availability. The Rich Results Test needs an image for product results, and the Schema Markup Validator does not.
What validators cannot tell you
A clean result means the markup is well formed. It does not mean the markup is true.
Check these by hand:
- Prices, dates, ratings, and names match what the page shows.
- Every entity in the markup is on the page.
- The test URL is the canonical page, not a staging copy.
After publishing, the enhancement reports in Google Search Console show problems found across the whole site. They catch template bugs that affect many pages and that a single-page test would miss.
Exercise
A page's Product markup passes the Schema Markup Validator with no errors, but the Rich Results Test reports an error. Give one likely reason, and say which tool to trust for Google rich results.
Show answer
Google requires properties that schema.org treats as optional, such as image or offers on a Product, so the markup is valid vocabulary but incomplete for Google. Trust the Rich Results Test for Google eligibility. Use the Schema Markup Validator for general vocabulary correctness.