Skip to Content
OpportunitiesTechnicalIssue ReferenceStructured DataJSON-LD block that is not valid JSON

JSON-LD block that is not valid JSON

What it is

At least one <script type="application/ld+json"> block on the page cannot be parsed as JSON. A single syntax error, such as a trailing comma, a missing quote or a line break inside a value, makes the whole block unreadable, not just the line it sits on.

Why it matters

Markup that does not parse cannot be read, so everything in that block is lost: its chance at rich results and the facts it gives Google to understand the page . Other valid blocks on the page still count. Visitors see nothing wrong, so broken markup can go unnoticed for months, often after a template edit or a plugin update.

How Asky checks it

Asky reads the page’s raw HTML and runs each <script type="application/ld+json"> block, the type in any letter case, through a strict JSON parser. A block that fails is reported with the parser’s message and its first 500 characters. Strict means no trailing commas, comments, single quotes, unquoted keys or raw line breaks inside strings, and an empty block fails too. The page carries one finding however many blocks fail, showing the last one that failed. JSON-LD added by JavaScript is not read. Blocks that parse are checked for a missing @type or @context instead; one holding only null, a number or a string raises both.

Reported as an error with high severity.

How to fix it

  1. Open the finding to see the parser’s message and the start of the broken block.
  2. Paste the block into a JSON linter, which names the line and column where parsing stops.
  3. Fix the usual causes: a comma after the last item, a missing quote, bracket or brace, a double quote inside a value that is not escaped as \", a line break inside a value, a comment, or quotes your CMS turned into &quot;.
  4. If CMS fields fill the block, such as a title with quotes or a description with line breaks, change the template so it encodes each value as JSON (for example with JSON.stringify) and escapes <, so a value cannot close the script early, instead of pasting the text in.
  5. After fixing, check that the block still has @context and @type at its top level.

Example

The Product block on https://example.com/products/desk-lamp breaks at its last property, where a comma follows the final value:

Before, the end of the block (the comma after "DL-200" breaks it): "name": "Desk Lamp", "sku": "DL-200", } After: "name": "Desk Lamp", "sku": "DL-200" }

← Back to Structured Data

Last updated on