Broken JSON-LD: what we found on 4,250 sites, and how to catch it

We audited 46,852 pages on 4,250 company and docs sites (up to a dozen pages each) for structured data. 2,755 of the sites (65%) had no JSON-LD on any page we checked. On the sites that had some, we found these problems:

Invalid JSON is the one that silently throws away everything else in the block, so we fetched the 41 sites again on 27 November 2026 to see why. 34 were still broken (5 had fixed it, 2 we couldn't fetch).

1. The eight ways JSON-LD breaks

10 of the 34 were Webflow sites. Webflow doesn't write JSON-LD itself, so every block there was typed or pasted into custom code by hand.

2. The fix: let the platform write the JSON

Every one of these goes away when the block is built as data and serialized by a JSON encoder, instead of being typed out or assembled from strings. The encoder adds the commas and braces and escapes quotes and line breaks. One more step for values a page author controls: write < as \u003c, so a </script> inside a value can't end the block early.

3. FAQPage and HowTo: leave them, don't add more

Google stopped showing FAQ rich results for everyone on 7 May 2026 (since August 2023 only well-known government and health sites had still got them) and removed its FAQ documentation on 15 June 2026. How-to rich results ended on 13 September 2023. Google has said that structured data it doesn't use causes no problems in Search and doesn't need to be removed, so this isn't urgent. Just don't add FAQ markup to new pages expecting expandable answers in the results, and drop it the next time you touch the template if nothing else reads it.

4. Check your build

This script parses every JSON-LD block in your built HTML and lists invalid JSON (with the text around the error), blocks without @context, nodes without @type, and retired FAQPage/HowTo types. Save it as check-json-ld.mjs, build, then run node check-json-ld.mjs dist (or public, _site, site, build, out; Node 20 or later). It exits with 1 when a block is broken, so it can run in CI.

import { readdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
const dir = process.argv[2] ?? "dist";
const retired = new Set(["FAQPage", "HowTo"]);
let bad = 0;
for (const f of readdirSync(dir, { recursive: true }).filter((f) => f.endsWith(".html"))) {
  const html = readFileSync(join(dir, f), "utf8");
  for (const [, body] of html.matchAll(/<script[^>]*type=["']?application\/ld\+json["']?[^>]*>([\s\S]*?)<\/script>/gi)) {
    let data;
    try { data = JSON.parse(body); } catch (e) {
      const at = Number(/position (\d+)/.exec(e.message)?.[1] ?? 0);
      console.log("invalid JSON ", f, e.message.split(" (")[0], JSON.stringify(body.slice(Math.max(0, at - 40), at + 20)));
      bad++; continue;
    }
    const nodes = [data].flat().flatMap((n) => n?.["@graph"] ?? [n]);
    if (![data].flat().every((n) => n?.["@context"])) { console.log("no @context  ", f); bad++; }
    for (const n of nodes) {
      const types = [n?.["@type"] ?? []].flat();
      if (!types.length) { console.log("no @type     ", f); bad++; }
      for (const t of types) if (retired.has(t)) console.log("retired type ", f, t);
    }
  }
}
process.exitCode = bad ? 1 : 0;

We tested it on pages built from the real mistakes above. For a live page, including a Webflow or WordPress site with no build folder, paste the URL into the free structured data checker: it shows the parse error, a missing @context or @type, retired types and the properties Google requires for each rich result.

Automating it with Headlark

Headlark's build step runs after your static build and writes the title, description, Open Graph and X tags and structured data into each page from its own content. It adds the JSON-LD types a page doesn't have yet and keeps the ones you wrote.

Try it

Try it free for 14 days on one site and up to 500 pages, no card needed. Add your site.