How Do You Validate JSON-LD Before Agents Discard It?
Published November 14, 2026 · Reviewed November 14, 2026 · Ingenious AI team
The short answer: Validate in two layers. Syntax: extract every application/ld+json block from your rendered pages and run each through a JSON parser — any failure is a build error, because agents discard unparseable blocks whole. Semantics: confirm the parsed blocks carry @context, declare the expected @type per template, and state an offers price and availability matching the visible page. AXO's structured-data dimension is the same check from outside — presence, validity, @context, types — so finish every validation round by pasting the page into the free audit and reading the dimension to 100.
What is JSON-LD validation?
JSON-LD validation is the verification that a page's structured-data blocks are (a) syntactically valid JSON that parsers accept, and (b) semantically correct — anchored with @context, classified with @type, and factually consistent with the page they describe. Syntax validation is fully automatable; semantic validation combines automated assertions with sampled human checks.
Layer one: the parser check
The check is deliberately primitive: find script elements of type application/ld+json in the rendered HTML, take their text, parse as JSON, record pass/fail per block. Twenty lines in any stack. Run it in three places: in CI against template fixtures (catches generator bugs before deploy), as a post-deploy smoke test against live pages (catches injection and caching corruption), and on a schedule against a sample of live product pages (catches data-dependent breakage — the quoted product name that only exists on one SKU).
Data-dependent breakage is why fixture-only checking is insufficient: your templates may be perfect while one product's data corrupts its block. Sampling live pages — say, the 50 most-viewed products weekly — covers the realistic failure surface. Any failure anywhere is treated as a defect in the generator, because per-instance patching does not scale and does not survive the next product import.
Layer two: semantic assertions
Parsing proves the block is JSON; assertions prove it is the right JSON. Automatable assertions per template: @context equals https://schema.org; @type matches the template's expected entity (Product on product pages, ItemList on listings); the Product's offers exists with price, priceCurrency, availability present. These are cheap dictionary checks on the parsed object, and they catch the second failure class — valid blocks that say the wrong thing, like the typeless block in the @context/@type guide.
One assertion deserves special status: offers price equals the price the page displays, compared on sampled live products. It requires rendering both values from the same page view, which is more work than a static check — and it is the assertion that defends the trust property everything else builds on. Quarterly is an acceptable cadence if generation is single-sourced; monthly if it is not.
Where validation lives in the pipeline
Validation that lives in a wiki page does not exist. It lives in: the CI job that blocks a merge when a fixture's block fails; the deploy pipeline's smoke step; the weekly scheduled job whose failure opens a ticket or a chat alert. Each placement catches a different entry point for breakage (code, deployment, data), and serious stores run all three because breakage uses all three doors.
Alert routing matters as much as the checks. A validation failure sent to an unmonitored inbox is a silent failure with extra steps. Route it where deployment failures go — the channel whose silence means health. The feed freshness alerts in the sync guide follow the same doctrine: machine checks, human-visible failures.
Using the audit as the external check
Your pipeline validates from inside; the audit validates from the consumer's seat. Paste each template's representative page into the free audit after significant changes and read the structured-data dimension: blocks found, all parsing, @context present, types listed. A 100 there means an outside parser, given only your served page, reconstructs exactly the data layer you intended.
Disagreements between your pipeline and the audit are diagnostic gold. Pipeline green, audit red usually means the served page differs from the fixture (caching, injection, geo variants) — the audit just did you the favour of reading the page your customers' agents actually get. Audit green, pipeline red means your fixtures are stricter or staler than production — align them before the strictness is needed.
The failure taxonomy to log against
When validation catches something, log it in one of four buckets so the pattern is visible over time: SYNTAX (block unparseable — generator encoding bug), ANCHOR (missing/wrong @context), TYPE (missing or unexpected @type), FACT (valid block, wrong values — price/availability mismatch). A quarter's log usually shows one bucket dominating, and that bucket names your real problem: tooling, templates, or data governance.
Stores are often surprised that FACT dominates once syntax is fixed. That is the mature state of a data layer: the machinery works, and the remaining work is truth-telling — the sales process updating blocks, the stock system feeding availability honestly. Validation's job evolves from policing punctuation to auditing testimony, which is the correct direction for effort to move.
A validation routine you can adopt today
Today: extract and parse the blocks on your five most-viewed product pages by hand (browser source plus any online JSON validator) and note the results. This week: script the same check and run it against fifty products. This month: wire it into CI and the deploy smoke test, add the semantic assertions for your main templates, and schedule the weekly sample. Thereafter: it runs itself, and your only job is responding when it speaks.
None of this requires new vendors or platform features; it requires deciding that structured data is production code with production standards. The stores that validate are the stores whose broken-block stories are about other stores.
The 5-action validation routine
- Parse every block: extract ld+json from rendered pages and JSON-parse each one; any failure is a defect.
- Assert the semantics: @context correct, @type matches the template, offers complete with price, currency, availability.
- Cross-check facts on samples: offers price equals the displayed price on live products, on a schedule.
- Run it in three places: CI on fixtures, smoke tests after deploy, weekly samples of live pages — failures routed to a monitored channel.
- Confirm from outside: paste each template into the free audit and read structured data to 100 after changes.
Worked example: validation week at a mid-size electronics store
Example — fictional, for illustration. An electronics store with 2,300 products adopts the routine. Day one's manual check of five pages: all parse. The scripted run over fifty products finds 6 invalid blocks — every one on a product whose name contains a double quote (a run of 'Pro "X"' monitor bundles), all generated by an app interpolating names into a JSON string. The semantic assertions find a second, quieter issue: the category template's ItemList blocks lack @context (an old app again).
Fixes land within the week: the app is replaced by encoder-generated theme blocks, CI gains the parser check, and the deploy smoke test samples the top fifty products. The following month's scheduled runs are clean, and the store's AXO structured-data dimension sits at 100 across all four templates. The owner's summary for the board is one sentence: 'We now learn about broken markup from our own pipeline, in minutes, instead of from the market, in quarters.'
Related guides and the standing invitation
Companion reading for this topic: Why Is Broken JSON-LD Worse Than No JSON-LD? · What Do @context and @type Mean in JSON-LD? · How Many JSON-LD Blocks Should a Page Have? · How Do You Add JSON-LD Product Markup to a Product Page?.
Whatever this guide led you to change, prove it the way every guide in this series ends: re-run the free audit on the same page and compare the dimension it names, read how the audit works if a finding is unclear, and see plans if you want the full guidance report and re-audit history while you work. A change you have not re-measured is a hope, not a fix.
Sources
- JSON-LD 1.1 — W3C Recommendation — the W3C Recommendation (2020) defining the JSON-LD syntax the markup in this guide uses.
- Product structured data — Google Search Central — Google Search Central's documentation for Product markup — how Google reads and validates it (current as of 2026).
- Schema.org — Product — the Schema.org vocabulary entry for Product — the type and properties this guide's markup names (current as of 2026).
Frequently asked questions
What are the two layers of JSON-LD validation?
Syntax: every ld+json block parses as valid JSON. Semantics: parsed blocks carry @context, the expected @type for the template, and complete, accurate offers. Syntax is fully automatable; semantics combines automated assertions with sampled fact-checks against the visible page.
Where should validation run?
In CI against template fixtures, as a post-deployment smoke test on live pages, and on a weekly schedule sampling live products. Each placement catches a different breakage door: code, deployment, and data.
Why sample live pages if CI passes?
Because some breakage is data-dependent: a single product name containing a quote can corrupt its block while every fixture passes. Sampling the most-viewed live products covers the realistic failure surface.
How does AXO's audit relate to my own validation?
The audit is the same check from the consumer's seat: it reports blocks found, validity, @context, and types for the page you paste. Pipeline-green but audit-red means the served page differs from your fixtures — cache, injection, or variants — which is itself the finding.
What should a validation failure trigger?
A defect against the generator, routed to a monitored channel like deployment failures. Fix the generation path, not the individual product's data, and let the checks prove the class of bug is closed.