Skip to content
SEOScanShopify SEOStructured Data
Critical SeverityStructured Data

Shopify JSON-LD Parse Error: Finding and Fixing Broken Schema

Search intent: diagnose · Updated February 2026

Direct Answer

A Shopify JSON-LD parse error occurs when a <script type="application/ld+json"> block contains invalid JSON - the most common causes are unescaped Liquid output injecting apostrophes or quotes into string values, HTML entities like &amp; appearing inside JSON strings, trailing commas before closing braces, and raw Liquid tags ({% %} or {{ }}) that were not processed because they appeared in the wrong context. Google cannot read any schema from a block with a parse error, making all rich results (stars, prices, breadcrumbs) impossible for that page.

Quick Diagnostic Checklist

  • Go to any product page → View Source → search for "application/ld+json"
  • Copy the schema block content into jsonlint.com - does it show a syntax error?
  • Check Google Search Console → Enhancements → Products for "Invalid JSON" errors
  • Search your schema template files for {{ variables }} not using | json filter

Not sure if your store has this issue?

Run a free scan to detect structured data problems instantly.

Free Scan

What This Issue Means

JSON-LD (JavaScript Object Notation for Linked Data) is the format Google prefers for reading structured data. It must be valid JSON - strictly. A single misplaced comma, an unescaped apostrophe in a product name, or an HTML entity inside a string value breaks the entire block. When this happens, Google's schema parser throws an error and ignores all the structured data in that block. You can have perfectly written Product schema with aggregateRating and offers - none of it matters if the JSON is malformed.

What Causes It (Shopify-Specific)

1

Liquid output not escaped with | json

The most common cause. If you output {{ product.title }} directly inside a JSON string and the product title contains an apostrophe (e.g. "Men's Jacket"), the result is invalid JSON: "name": "Men's Jacket". The | json filter correctly outputs "name": "Men\u0027s Jacket" - always use it for any string value.

2

HTML entities inside JSON strings

Some Liquid filters (like | escape or | html_escape) convert & to &amp; and " to &quot;. Inside a JSON string, &amp; is not the & character - it's a literal string of 5 characters. JSON parsers do not decode HTML entities, so the resulting JSON is technically valid but semantically wrong, and can break downstream validators.

3

Trailing commas before closing braces

Conditional Liquid blocks inside schema often leave trailing commas. For example: {"name": "X", {% if condition %}"field": "Y",{% endif %}} - if the condition is false, the output is {"name": "X",} which is invalid JSON (trailing comma). Use conditional comma placement or a Liquid join pattern to avoid this.

4

Raw Liquid tags in wrong template context

Snippets or sections included inside a JSON-LD block sometimes output raw Liquid tags ({{ variable }}) when the variable is undefined or when the snippet was designed for HTML context, not JSON context. The result is JSON containing literal {{ }} characters, which are not valid JSON.

How to Detect It Manually

  1. 1Open any product/collection page → right-click → View Source
  2. 2Press Ctrl+F, search for "application/ld+json" - find all schema blocks
  3. 3Copy each block's content (between the <script> tags) into jsonlint.com
  4. 4Alternatively paste the full page URL into search.google.com/test/rich-results - any parse errors appear as "Invalid JSON" warnings
  5. 5In Google Search Console → Enhancements → Products (or Breadcrumbs etc.) → look for "Invalid JSON" errors with affected URL count
  6. 6Browser DevTools → Console tab - JSON parse errors from ld+json blocks sometimes appear here as warnings

How to Fix It (Step-by-Step)

1

Always use | json for Liquid string values in schema

Replace every instance of {{ variable }} inside a JSON string with {{ variable | json }}. The | json filter handles escaping apostrophes, quotes, newlines, and other special characters automatically.

liquid
{
  "@type": "Product",
  "name": {{ product.title | json }},
  "description": {{ product.description | strip_html | json }},
  "sku": {{ product.selected_or_first_available_variant.sku | json }}
}
2

Strip HTML before applying | json to description fields

Product descriptions often contain HTML tags. Apply | strip_html before | json to ensure clean text output: {{ product.description | strip_html | truncate: 5000 | json }}

liquid
"description": {{ product.description | strip_html | truncate: 5000 | json }},
3

Fix trailing commas from conditional blocks

Use an array-join pattern to avoid trailing commas in conditional schema fields.

liquid
{%- liquid
  assign schema_parts = ''
  if product.metafields.judgeme.badge
    assign rating_block = ',"aggregateRating":{"@type":"AggregateRating","ratingValue":' | append: product.metafields.judgeme.average | append: ',"reviewCount":' | append: product.metafields.judgeme.count | append: '}'
    assign schema_parts = schema_parts | append: rating_block
  endif
-%}
{
  "@type": "Product",
  "name": {{ product.title | json }}
  {{- schema_parts -}}
}
4

Validate every schema block with Google's Rich Results Test

After fixing, paste each affected URL into search.google.com/test/rich-results. Confirm "Detected items" shows your schema types with no "Invalid JSON" warnings. Submit URLs for reindexing via Search Console → URL Inspection.

How SEOScan Detects This Issue

SEOScan extracts every <script type="application/ld+json"> block from the page HTML and runs JSON.parse() on each. Any block that throws a SyntaxError is flagged as a critical parse error with the specific error message and character position. SEOScan then identifies the likely cause: Liquid output patterns ({{ }} visible in source), HTML entities (&amp;, &quot;), or trailing comma patterns. The fix recommendation is specific to the detected cause.

Example Scan Result

JSON-LD parse error: SyntaxError at position 247Critical

Description

Product schema block on /products/mens-jacket contains invalid JSON. Error: SyntaxError: Unexpected token ' in JSON at position 247. Cause: product.title output "Men's Jacket" without | json filter - apostrophe breaks JSON string.

Impact

Google cannot read any structured data from this block. Product rich results (stars, price, availability) are impossible until fixed. Affects all product pages using this schema template.

Recommended Fix

Replace {{ product.title }} with {{ product.title | json }} in your schema block. Apply | json to all Liquid string variables in JSON-LD blocks. Validate with Google's Rich Results Test.

Code

{
  "@type": "Product",
  "name": {{ product.title | json }},
  "description": {{ product.description | strip_html | json }}
}

Why It Matters for SEO

Blocks All Rich Results

A single parse error in a schema block makes the entire block unreadable by Google. Stars, prices, availability badges - all require valid schema. A parse error is a complete blocker, not a partial issue.

Silent Failure

Parse errors fail silently. Your page looks fine to users. The schema appears to be there when you view source. Only Google's schema parser (and tools like Rich Results Test) reveal the error.

High Prevalence on Shopify

Shopify's Liquid templating makes this common because product titles, descriptions, and metafield values routinely contain apostrophes, quotes, and special characters that break naive JSON string output.

Quick to Fix, High Return

Once fixed with | json, the error is permanently resolved for all products - including future products with special characters. It's typically a 5-minute fix with an outsized SEO impact.

Real-World Validation Signals

  • Google Search Console's Rich Results report frequently shows 'Invalid JSON' as the top error category for Shopify stores - more common than missing fields or wrong types.
  • The | json filter has been the correct Liquid approach for schema output since Shopify introduced it - stores missing this have often copied schema from pre-2018 tutorials.
  • Stores that fix JSON-LD parse errors see Google begin parsing and caching their schema within 7–14 days of re-crawling, based on GSC enhancement report improvements.
  • Apostrophes in product names (like "Men's", "Women's", "It's") are the single most common cause - endemic to fashion, lifestyle, and beauty Shopify stores.

When this may not need fixing

If Google's Rich Results Test shows your schema as valid with no parse errors, and Search Console shows no 'Invalid JSON' reports, your schema is fine. Some stores use third-party schema apps that output valid JSON independently - check that those are also parsing cleanly before making changes.

Frequently Asked Questions

Q: What is a JSON-LD parse error?

A JSON-LD parse error means the structured data block on your page contains invalid JSON that cannot be parsed by Google's schema reader. The most common cause on Shopify is Liquid output variables that inject special characters (apostrophes, quotes) into JSON strings without proper escaping.


Q: Does a JSON-LD parse error affect my whole site?

It affects every page that uses the same schema template - typically all product pages if the error is in your main-product.liquid schema block. It does not affect pages with separate, valid schema blocks.


Q: Will Google penalise me for a JSON-LD parse error?

No - Google ignores malformed schema rather than penalising you. The effect is that you lose all rich result eligibility (stars, prices, etc.) for affected pages. It's a missed opportunity, not a ranking penalty.


Q: How do I check if my JSON-LD has a parse error?

Paste your page URL into Google's Rich Results Test (search.google.com/test/rich-results). If a schema block has a parse error, it appears as 'Invalid JSON' with the error position. You can also copy the raw schema block content from your page source into jsonlint.com for a detailed diagnostic.


Q: What is the | json Liquid filter and why does it fix this?

The | json Liquid filter converts any value to a valid JSON-encoded string, automatically escaping apostrophes, double quotes, newlines, and other characters that would break JSON syntax. It's the correct way to output any Liquid variable inside a JSON-LD block.

Check Your Store for This Issue

SEOScan automatically detects shopify json-ld parse error: finding and fixing broken schema and 5 related issues - with specific fixes for your store.

Run Free Scan

Related Issues