Fix unparsable JSON-LD caused by quotes and commas in page templates
Serialize the whole schema object and test the values that break hand-built JSON.
TL;DR: Fix unparsable JSON-LD in the shared template by serializing a complete data object, then test quoted text, empty values and multiple records.
A page can look correct while its structured data fails to parse. The visible headline and the JSON-LD script travel through different output rules, so a harmless quotation mark in a CMS field can break every page using the same template. Editing one affected page leaves that template ready to fail again.
Why do quotes and commas break JSON-LD templates?
JSON-LD uses JSON syntax. A comma inside a quoted string is ordinary text; a comma between properties separates them. The failure comes from emitting content as syntax, or manually assembling separators around optional fields. The JSON grammar in RFC 8259 requires quoted property names and escaped quotation marks inside strings.
Consider a CMS title of Fix "Retry, later" alerts. This deliberately broken JavaScript builds JSON by pasting that title between another pair of quotes:
const title = 'Fix "Retry, later" alerts';
const broken = '{"@type":"Article","headline":"' + title + '"}';
JSON.parse(broken); // SyntaxErrorThe inner quotation mark ends the JSON string too soon. Removing commas from the title changes the content without repairing the encoder. An optional description can expose another defect: the template leaves a separator after omitting the field.

How do you find the template that owns the error?
Start with one affected URL and copy every application/ld+json block from the served page. Parse each block separately, then match the failing property to its template or plugin. Google identifies an underlying template as the common cause when the same parsing error affects many pages.
- Save the failing page's original response, including the exact title and optional fields.
- Reduce the failing block to an empty object and add properties back until the syntax fails.
- Find the code that emits that property across the page family, including archived or translated templates.
- Check whether both a plugin and a theme emit independent blocks; each block needs its own successful parse.
Google's unparsable structured data report describes syntax errors that prevent it from determining the intended structured-data type. A later missing-property warning is a separate validation stage.
How do you serialize JSON-LD without manual separators?
Build the object first and serialize it once at the HTML boundary. Use the JSON encoder supplied by your language or framework, rather than concatenating strings that happen to resemble JSON. Preserve the content value and let the encoder escape it.
function articleJson(title, description) {
const data = {
'@context': 'https://schema.org',
'@type': 'Article',
headline: title,
};
if (description !== '') data.description = description;
return JSON.stringify(data).replace(/</g, '\\u003c');
}This example accepts strings for both arguments. Check their types before calling it if CMS data can contain nulls or objects. The optional description is omitted as a property, so there is no separate comma to manage. Empty required content still needs an editorial or schema check even when its JSON parses.
The Next.js JSON-LD guide uses serialization followed by replacing literal less-than characters with their JSON Unicode escape. That extra step matters when a serialized value is embedded in an HTML script element: a value containing a closing script tag must remain data.
Follow your framework's documented safe script insertion method. Do not run a generic HTML entity encoder over the finished JSON, and do not paste a second pair of quotes around already serialized values. In a CMS, change the shared renderer or the responsible plugin configuration.

How do you test quotes, empty text and multiple records?
Keep a small regression set beside the template. Include the original quoted title, a different value containing backslashes and a newline, an empty optional description, and two records in one collection. For each result, parse the emitted JSON and compare the recovered value with the input.
The local example checks for this article verified those round trips with Node.js. A closing-script value also survived serialization without a literal less-than character in the output. These checks exercise the encoder; they do not validate a deployed site's schema or Google eligibility.
const title = 'Fix "Retry, later" alerts';
const parsed = JSON.parse(articleJson(title, ''));
console.assert(parsed.headline === title);
console.assert(!Object.hasOwn(parsed, 'description'));
const records = [{ name: 'A, B' }, { name: '"C"' }];
console.assert(JSON.parse(JSON.stringify(records)).length === 2);Serialize a collection as an array or an appropriate @graph object. Printing two object literals next to each other does not create one JSON document. A normal title such as Retry alerts belongs in the checks too, so the repair preserves the neighboring case that already worked.

What should you verify after deploying the template fix?
Fetch representative URLs from every affected template after cache invalidation. Confirm that the live script contains the new output, parses successfully and describes the visible page. Then run the Rich Results Test for supported features and use Validate Fix in the report after the whole affected group is repaired.
The JSON standard settles syntax questions; it cannot decide whether an Article has the right properties for a search feature. Record the syntax result separately from schema requirements and search appearance.
For that later stage, distinguish FAQPage schema design from a syntax repair. The broader AI Overview eligibility checks also include access and content issues that valid JSON alone cannot solve.
For other workflow failures, the Automation Error Index groups errors by platform and cause.
FAQ
Do commas in a page title make JSON-LD invalid?
No. Commas inside a serialized string are valid text; missing or extra separator commas outside strings cause syntax failures.
Should quotes be removed from CMS content?
Preserve valid editorial content and fix the serialization boundary. The same renderer must also handle backslashes, line breaks and optional values.
Why are new schema errors visible after parsing is fixed?
The parser can now read the object, so later validation can inspect its properties. Repair those errors against the requirements for the intended schema type.
Does valid JSON-LD guarantee rich results or AI citations?
No. A syntax pass only confirms readable JSON; feature eligibility, content quality and search selection remain separate decisions.