Menu

How to validate JSON-LD in a CI pipeline with Node and a schema validator
📰

How to validate JSON-LD in a CI pipeline with Node and a schema validator

DEV Community: javascript·Usman Ishaq·about 7 hours ago
#iskouIlm
#devtojavascript#devto#dev#json#schema
Long article (1138 words) — no AI summary yet.
Reading 0:00
15s threshold

To validate JSON-LD in CI, run a script after the build that reads every HTML file, parses each JSON-LD block, checks it against a JSON Schema and exits with code 1 on any error. This post gives a Node script that does this with Ajv, tested locally, and says exactly what it does not check.

Usman Ishaq is a semantic SEO strategist and consultant, and the founder of Digital Vikingz. Markup is written from the visible page outward, and a template change can silently break it. A check in the pipeline catches that before it ships.

What does the check cover?

The script covers three things and ignores the rest.

Covered: each built page has at least one JSON-LD block, each block is valid JSON, and each business or Service node matches a JSON Schema that this project defines.

Not covered: schema.org vocabulary in general, eligibility for Google rich results, and whether the markup matches the visible text.

The schemas

Install the packages with npm install ajv ajv-formats , set "type": "module" in package.json…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.