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:
- Retired markup: 538 sites (13% of all) still ship
FAQPage, on 2,322 pages, and 40 shipHowTo. Neither gets a rich result in Google any more. - Invalid JSON: 41 sites had a JSON-LD block that doesn't parse. Google can't read any of that block; Search Console lists it under "Unparsable structured data".
- No
@context: 40 sites. Without"@context": "https://schema.org"the types don't mean anything to a parser. - No
@type: 28 sites had a node without one.
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
- Braces that don't balance (7 sites). An extra
}at the end, or a closing brace missing after a nested object such asaddressoraggregateRating. - HTML inside the JSON (5 sites). A post's HTML body with real line breaks in
articleBody,<br />tags after every line from a template that converts line breaks, and on two sites a<script>or<meta>tag that ended up inside the block. - A missing comma (5 sites). Between two properties, or between the items a template loop printed (
} {instead of}, {). - Unescaped quotes (4 sites). A title or name that contains quotation marks, like
"name": "James "Chris" Smith". The template printed the text as is instead of encoding it. - A template value that wasn't filled in (4 sites).
"description": ,when the field was empty,"name": provinceNamewhere a variable was meant, an array printed inside quotes ("image": "["https://…), a URL without quotes. - A trailing comma (3 sites).
"name": "Example",right before the}. JavaScript allows it; JSON doesn't. - A plugin's HTML in a date (3 sites, all MkDocs).
"dateModified": "<span class="git-revision-date-localized-plugin …. The git-revision-date-localized plugin'spage.meta.git_revision_date_localizedis wrapped in a<span>for the page footer. - Something else (3 sites). A
// Not supported yetcomment (JSON has no comments), debug output with terminal colour codes where the JSON should be, and an FAQ question used as a property name.
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.
- Astro, Next.js, Gatsby, Eleventy (JavaScript):
JSON.stringify(data).replace(/</g, "\\u003c")into the script tag. See Next.js, Gatsby and Eleventy. - Hugo: build a dict and pipe it through
jsonify; see JSON-LD in Hugo. - Jekyll:
jsonifyon every value; see JSON-LD in Jekyll. - MkDocs:
tojsonin the template, andpage.meta.git_revision_date_localized_raw_iso_date(a plain date such as2026-11-27) fordateModifiedinstead of the variable with the<span>. See JSON-LD in MkDocs. - WordPress:
wp_json_encode()in awp_headhook rather than JSON pasted into a post or widget; see SEO for WordPress. - Webflow: check each hand-written block before you paste it, and after you publish, check a few CMS items whose fields contain quotes or line breaks if the template puts CMS fields into the JSON.
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.