npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gsriram24/structured-data-validator

v1.7.3

Published

Structured Data Validator

Readme

@gsriram24/structured-data-validator

Fork of @adobe/structured-data-validator with additional features.

NPM Version Node Current

A JavaScript library for validating and parsing structured data according to Schema.org specifications and Google Rich Results requirements.

Additional Features in This Fork

This fork adds the following features on top of Adobe's original library:

1. fieldNames Property on Validation Errors

Every validation error now includes a fieldNames array for precise programmatic access:

// Before (Adobe's version) - requires string parsing
{
  issueMessage: 'Required attribute "price" is missing',
  severity: 'ERROR',
  path: [...]
}

// After (this fork) - direct field access
{
  issueMessage: 'Required attribute "price" is missing',
  severity: 'ERROR',
  path: [...],
  fieldNames: ['price']  // ✨ New!
}

For or() conditions with multiple fields:

{
  issueMessage: 'One of the following attributes is required...',
  fieldNames: ['aggregateRating', 'offers', 'review']  // All relevant fields
}

Access the primary field with error.fieldNames[0]}, or iterate over all fields as needed.

2. New Validators for Common Schema Types

Added validators for commonly-used schema.org types:

| Type | Required Fields | |------|-----------------| | LocalBusiness | name, address | | Article | headline | | Event | name, startDate, location (or online mode) | | FAQPage | mainEntity | | HowTo | name, step | | WebSite | name, url |

3. Automatic Subtype Inheritance

Subtypes automatically inherit validation from parent types:

| Subtype | Inherits From | |---------|---------------| | Restaurant, Store, Hotel, Dentist | LocalBusiness | | NewsArticle, BlogPosting, TechArticle | Article | | MusicEvent, SportsEvent, Festival | Event |

This enables validation of 100+ schema types without individual validator files.


Installation

npm install @gsriram24/structured-data-validator

Usage

import { Validator } from '@gsriram24/structured-data-validator';
import WebAutoExtractor from '@marbec/web-auto-extractor';

// Extract structured data from HTML
const extractor = new WebAutoExtractor({ addLocation: true, embedSource: ['rdfa', 'microdata'] });
const extractedData = extractor.parse(sampleHTML);

// Fetch the current schema.org schema
const schemaOrgJson = await (await fetch('https://schema.org/version/latest/schemaorg-all-https.jsonld')).json();

// Create a validator instance
const validator = new Validator(schemaOrgJson);

// Validate the extracted structured data
const results = await validator.validate(extractedData);

// Use fieldNames for precise error handling
results.forEach(issue => {
  if (issue.severity === 'ERROR') {
    console.log(`Field "${issue.fieldNames?.[0]}" has error: ${issue.issueMessage}`);
  }
});

Browser

const { default: WebAutoExtractor } = await import(
  'https://unpkg.com/@marbec/web-auto-extractor@latest/dist/index.js'
);
const { default: Validator } = await import(
  'https://unpkg.com/@gsriram24/structured-data-validator@latest/src/index.js'
);

const extractedData = new WebAutoExtractor({
  addLocation: true,
  embedSource: ['rdfa', 'microdata'],
}).parse(document.documentElement.outerHTML);

const schemaOrgJson = await (
  await fetch('https://schema.org/version/latest/schemaorg-all-https.jsonld')
).json();

const issues = await new Validator(schemaOrgJson).validate(extractedData);
console.log(issues);

Upstream Contributions

The features in this fork have been submitted as PRs to the upstream Adobe repository:

Once merged upstream, consider switching back to @adobe/structured-data-validator.

Development

Prerequisites

  • Node.js (>=18.0.0)
  • npm

Setup

git clone https://github.com/gsriram24/structured-data-validator.git
cd structured-data-validator
npm install

Available Scripts

  • npm test - Run tests with coverage
  • npm run lint - Run ESLint
  • npm run format - Check code formatting
  • npm run format:fix - Fix code formatting issues

License

Apache-2.0 (same as upstream)

Credits

Original library by Adobe.