Skip to content

JSON syntax error in structured data (JSON-LD)

jsonld-syntax-errorserious
On this page

Why it matters

  • Google reads structured data from JSON-LD blocks to show rich results, such as business details, prices and ratings.
  • When a block is not valid JSON, Google cannot read anything in it: the whole block is ignored, not just the broken line. Search Console lists this case in its "Unparsable structured data" report.
  • Known causes: an extra comma after the last item, a quote inside an Arabic name such as مطعم "الأصيل" left unescaped, and a line break inside a text value.

Example

Wrong
<script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "Restaurant",
    "name": "مطعم "الأصيل" للمأكولات البحرية",
Right
<script type="application/ld+json">
  {
    "@context": "https://schema.org",
    "@type": "Restaurant",
    "name": "مطعم \"الأصيل\" للمأكولات البحرية",

How to fix

  • Remove the comma before } or ].
  • Escape a quote inside text as \", or use the Arabic quotation marks «», which need no escaping:
json
{
  "@context": "https://schema.org",
  "@type": "Restaurant",
  "name": "مطعم \"الأصيل\" للمأكولات البحرية"
}
  • Better still, generate the block with your language's JSON encoder, such as JSON.stringify in JavaScript or json_encode in PHP, instead of writing it as text by hand.
  • After the fix, test the page with Google's Rich Results Test or the Schema.org validator.

How we detect

  1. We collect every <script type="application/ld+json">, in any letter case and with any parameters after the type, and skip empty blocks.
  2. We check each block strictly against the JSON specification (RFC 8259), and find the kind of error and its place in the page by line and column.
  3. Blocks are numbered in their order among the page's JSON-LD blocks; each broken block gives one finding, at its first error.

This rule checks the syntax only; whether the Schema.org types and properties are right is a separate check.