Skip to content

Latest commit

 

History

13 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ldlint

Finds schema.org mistakes that Google's Rich Results Test and most validators miss.

A fast CLI tool for validating JSON-LD against the schema.org vocabulary. Catches invalid properties, wrong types, and schema misuse that most tools don't detect.

Install

Prebuilt binaries

Download from the Releases page.

From source

go install github.com/kevhq/ldlint/cmd/ldlint@latest

Usage

# Validate HTML files in a directory (recursive)
ldlint dist/

# Validate specific files
ldlint index.html schema.json

# Validate a live URL
ldlint https://example.com/

# Pipe raw JSON-LD from stdin
echo '{"@type":"TouristTrip","guide":{}}' | ldlint -

# Mix and match
ldlint dist/ https://example.com/ -

# JSON output for CI
ldlint --format json dist/

# Refresh cached vocabulary
ldlint --refresh dist/

Example: catches an invalid guide property on TouristTrip

dist/en/tours/monte-alban/index.html
  TouristTrip
    ERROR  PROPERTY  "guide" is not valid on TouristTrip
                     ancestors: Trip > Intangible > Thing
                     valid on: CreativeWork, Event, ...
  LocalBusiness        OK (18 properties)
  WebSite              OK (5 properties)

1 file(s), 3 schema(s), 1 error(s)

Why not Google Rich Results Test?

Google's Rich Results Test only validates structured data for the specific rich result types it supports.

ldlint validates against the full schema.org vocabulary, including:

  • Non-rich-result schemas (TouristTrip, Person, ItemList, etc.)
  • Property misuse (valid property, used on the wrong type)
  • Full type hierarchy validation with inheritance

Read more: Schema.org mistakes that Google's validator won't catch

Error Categories

  • PROPERTY -- known type, invalid property (with "valid on" hint)
  • SUPERSEDED -- warning: the term still works, but schema.org names a replacement (e.g. serviceArea -> areaServed)
  • TYPE -- unknown schema.org type
  • PARSE -- invalid JSON in a JSON-LD block. Reported against that block alone; the rest of the file is still validated
  • EXTRACT -- the input itself could not be read (unreadable file, failed fetch, non-200 response)

Warnings are reported but never affect the exit code.

Exit Codes

  • 0 -- no errors (warnings may still be present)
  • 1 -- validation errors found
  • 2 -- usage error, unreadable input path, or vocabulary fetch failure

How It Works

  1. Fetches the schema.org vocabulary and caches it locally (~7 day TTL)
  2. Builds a type hierarchy from rdfs:subClassOf and property domains from schema:domainIncludes
  3. Extracts JSON-LD blocks from HTML using an HTML parser (not regex)
  4. Validates each property against the type and all its ancestors
  5. Flags terms marked schema:supersededBy and names their replacement

Flags

Flag Description
--explain <Type> Show valid properties and ancestors for a type
--format text|json Output format (default: text)
--quiet Only show schemas with errors or warnings
--verbose Show property names for each schema
--no-color Disable colored output
--refresh Force refresh of cached vocabulary
--version Print version and exit

Supported Input

  • HTML files (extracts <script type="application/ld+json"> blocks, matched case-insensitively)
  • Raw JSON-LD files (.json, .jsonld)
  • URLs (http://, https://) -- fetched with a 30s timeout, redirects followed
  • Stdin (-)
  • @type as string or array of strings
  • @graph containers and top-level arrays, unwrapped to one schema each -- from any source
  • Single objects, arrays, or @graph wrappers

About

A fast CLI tool that validates JSON-LD structured data against the full schema.org vocabulary. Finds invalid properties, unknown types, and schema misuse that most validators miss.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages