---
title: "JSON-LD Syntax Error: How to Find and Fix It"
description: "Find and fix a JSON-LD syntax error: the usual causes, a script that parses every block, and fixes for Next.js, WordPress, Shopify and static sites."
url: https://seenlens.com/fixes/json-ld-syntax-errors
last_updated: 2026-11-06
---

# JSON-LD syntax error: how to find and fix it

A JSON-LD syntax error means the text inside the script tag is not valid JSON, so parsers skip the whole block. Typical causes are a trailing comma, single quotes, an unescaped quote in a value and a template placeholder left in. SeenLens fails the page and prints the parse error. Most fixes take under ten minutes.

By SeenLens. Last updated: 2026-11-06

## What does the JSON-LD parse check test?

SeenLens reads each JSON-LD block in the page HTML and tries to parse it as JSON. The check has four outcomes.

| Situation | Result |
| --- | --- |
| The page has no JSON-LD block | Not applicable |
| At least one block does not parse | Fail. The evidence names the block number and the parse error. |
| A block was too large to check | Warn |
| Every block parses | Pass |

The check tests syntax only. A block can parse and still use wrong property names or miss properties that Google needs. Test those with the Rich Results Test or the Schema Markup Validator.

Google says structured data should match what visitors see, and its tools report errors in Search Console. A block that cannot be parsed gives search engines nothing to use. No study shows a link between a syntax error and AI citations.

## How do I find the broken block?

Run this script. It fetches the page, extracts every JSON-LD block and prints the parse error with its position.

```text
curl -s https://example.com/page | python3 -c '
import sys, re, json
html = sys.stdin.read()
blocks = re.findall(r"<script[^>]*application/ld\+json[^>]*>(.*?)</script>", html, re.S | re.I)
print(len(blocks), "JSON-LD blocks")
for i, b in enumerate(blocks, 1):
    try:
        json.loads(b); print(i, "ok")
    except ValueError as e:
        print(i, "ERROR:", e)
'
```

An error such as `Expecting ',' delimiter: line 7 column 3` points to the line inside that block. Line 1 is the first line after the opening script tag.

## Which mistakes cause the error?

| Mistake | Wrong | Right |
| --- | --- | --- |
| Trailing comma | `"name": "A",}` | `"name": "A"}` |
| Single quotes | `'name': 'A'` | `"name": "A"` |
| Unescaped quote in a value | `"name": "The "Best" Shop"` | `"name": "The \"Best\" Shop"` |
| Line break inside a string | A value that runs onto the next line | Use `\n` or keep it on one line |
| Comment | `// logo` | Remove it. JSON has no comments. |
| Curly quotes from a document | `“name”` | `"name"` |
| Template placeholder left in | `"price": {{ price }}` | Fill it in on the server |
| Two objects side by side | `{...}{...}` | Use two script tags, or one `@graph` array |

## How do I fix it?

Build the JSON from data in code, not from hand written strings. A serializer escapes quotes and line breaks for you.

### Next.js

Create the object in code and call `JSON.stringify`. Escape the `<` character as the Next.js docs advise, so a value that contains a closing script tag cannot break the page.

```text
const json = JSON.stringify(jsonLd).replace(/</g, "\\u003c");
// <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: json }} />
```

### WordPress

Find which source prints the broken block: your SEO plugin, a schema plugin, the theme or a Custom HTML block. Turn the sources off one at a time and rerun the script. Fix or remove the broken one. If you pasted a block from a word processor or chat tool, replace curly quotes with straight quotes.

### Shopify

Liquid inserts text as it is. A product title with a double quote breaks the string. Use the `json` filter, which outputs a quoted and escaped JSON string.

```text
"name": {{ product.title | json }},
"description": {{ product.description | strip_html | json }},
```

### Static sites

Paste the block into a JSON validator or run the script above, fix the reported line and repeat until every block says ok. Generate the block from front matter with your site generator's JSON filter when you can.

## How do I verify the fix?

1. Run the script again. Every block must print `ok`.
2. Test the URL in the Rich Results Test and the Schema Markup Validator to catch schema errors.
3. Scan the page with SeenLens. The check must pass.

## When can I ignore this check?

Do not ignore a failure. A broken block is dead weight. If the block is not yours, such as one injected by a widget, remove the widget or ask the vendor to fix it. A page with no JSON-LD at all gets 'not applicable' here and fails [the presence check](https://seenlens.com/fixes/add-json-ld) instead.

[Scan your page with SeenLens](https://seenlens.com/)

## Common questions

### How do you fix a syntax error in JSON-LD?

Find the block and line from the parser message. Fix the missing comma, extra comma, quote or bracket on that line. Run the parser again until every block is ok.

### Is a JSON-LD block that parses also valid for Google?

Not always. Parsing only proves the JSON is well formed. Google's Rich Results Test checks that the types and properties fit the feature you want.

## Which checks are related?

- [Add JSON-LD](https://seenlens.com/fixes/add-json-ld) covers pages with no block.
- [Organization schema](https://seenlens.com/fixes/add-organization-schema) covers the entity types.
- [Add a publication date](https://seenlens.com/fixes/add-publication-date) covers the date properties.

## Sources

- [Google Search Central: Introduction to structured data](https://developers.google.com/search/docs/appearance/structured-data/intro-structured-data) (markup must match visible content; Rich Results Test; checked 2026-11-06)
- [Next.js docs: JSON-LD](https://nextjs.org/docs/app/guides/json-ld) (escaping the less-than character, Rich Results Test and Schema Markup Validator; page updated 2026-03-02; checked 2026-11-06)
- [Schema Markup Validator](https://validator.schema.org/) (general schema.org validation tool linked from the Next.js docs; checked 2026-11-06)
- [Shopify Liquid: json filter](https://shopify.dev/docs/api/liquid/filters/json) (converts a value to JSON; checked 2026-11-06)
