DEV Community

Cover image for How to Validate JSON-LD Schema Before Deployment
SEOGlint
SEOGlint

Posted on

How to Validate JSON-LD Schema Before Deployment

Structured data breaks quietly. A stray comma does not crash your site, it just makes the markup unreadable. Here is a short routine to validate JSON-LD and fix schema markup errors before you deploy.

Step 1: Is it valid JSON?

Parse it. If JSON.parse fails, nothing else matters. These four mistakes all fail here:

  • a trailing comma after the last property
  • single quotes instead of double quotes
  • an unquoted property name
  • a missing comma between two properties

When I tested these, two different mistakes (an unquoted key and a missing comma) produced the same parser message at the same position. Read the source at the reported location instead of trusting the wording.

Step 2: Does it have the right pieces?

A parser will accept {"@type": "Organization"}, but the markup is still incomplete. Check:

  • @context is present
  • @type is spelled correctly
  • the properties that type needs are there (name, mainEntity, itemListElement, startDate, thumbnailUrl and so on)

A misspelled type like Artical is valid JSON. In my test it showed a warning, not an error, so do not rely on a pass/fail count alone.

Step 3: Does it match the page?

Markup for FAQs or reviews that visitors cannot see is a common reason for problems.

Step 4: Use a second tool

A free schema markup validator tells you about syntax and properties. For Google features, also run Google's Rich Results Test, because valid markup is not the same as rich-result eligibility.

I wrote up all 12 test cases with the submitted code, the exact messages and suggested fixes: JSON-LD schema errors, tested. The free JSON-LD validator I used is SEOGlint's Schema Markup Validator. I built it, so treat my results as observations of that one tool.

Top comments (0)