Skip to content

tanphan1105/json-ld-schema-guardian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ JSON-LD Schema Guardian

Scan, validate, and repair corrupted JSON-LD structured data blocks in HTML files. Prevent Google from silently dropping your rich snippets.


😫 The Pain Point (Real Bug Found in Production)

We discovered a critical SEO bug: Particle.js animation code was silently injected into a <script type="application/ld+json"> block, causing the entire Product schema to become invalid JSON. Google stopped indexing the rich snippet. No error was thrown in the browser.

This is the tool we built to catch and kill this bug automatically.

πŸ’Š What It Does

# Scan for corrupted schemas
python json_ld_guardian.py index.html

# Auto-remove corrupted blocks
python json_ld_guardian.py index.html --repair

# Generate a valid Product schema template
python json_ld_guardian.py --generate-product

✨ Features

  • Finds all <script type="application/ld+json"> blocks in any HTML file.
  • Validates each block as strict JSON. Reports exact parse error location.
  • Detects JavaScript injection patterns (function(, var , document., etc.) that corrupt the schema.
  • Auto-removes corrupted blocks and logs a clear explanation.
  • Generates valid schema templates for Product, WebSite, Organization.

πŸ“– Real-World Case Study

Production landing page: Particle.js ran at page load, and a timing bug caused it to append function(){} into the JSON-LD block. The page looked perfect visually. But Google Search Console showed "Invalid JSON-LD" for 3 months before we caught it with this scanner.

"If Google can't read your schema, your rich snippets don't exist."

πŸ’– Support Open Research

If this script saved your Google indexing or prevented an SEO disaster, consider buying me a coffee. It fuels the continuous development of these B2B engineering tools!

ko-fi

About

Scan, validate and repair corrupted JSON-LD structured data in HTML. Prevents Google from silently dropping your rich snippets.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages