Skip to content

webdevbynight/schemata-validator

schemata-validator

Check the validity of Schema.org vocabulary used in JSON-LD and HTML microdata

License: MIT ESM-only package Conventional Commits 1.0.0 Checked with Biome Released with release-change NPM latest version Node support Build status

schemata-validator takes JSON-LD data and microdata in HTML and returns detailed validation results.

Installation

Install package for Node.js:

pnpm add --save-dev schemata-validator

You can also install it using npm:

npm install --save-dev schemata-validator

Usage

Options

data

Type: array

Specifies which JSON-LD data to be sent to validation. This option takes precedence over the other options.

files

Type: array
CLI arguments: -f <space-separated list of files>, --files <space-separated list of files>

Specifies which files to be sent to validation. This option takes precedence over the other options.

paths

Type: array
CLI arguments: -p <space-separated list of paths>, --paths <space-separated list of paths>

Specifies which folders or files to be sent to validation. When omitted, all files are validated (skipping the node_modules folder), unless the exclude option is specified.

exclude

Type: array CLI arguments: -e <space-separated list of paths>, --exclude <space-separated list of paths>

Lists strings to match in paths to skip. When omitted, all files specified by files options if defined (all files otherwise) are validated (skipping the node_modules folder).

dryRun

Type: boolean
Default: false CLI arguments: -d, --dry-run

Bypasses the validation (for usage while building CI).

CLI

schemata-validator can be used as a CLI tool.

schemata-validator [flags]

package.json scripts

You can run schemata-validator from the scripts section of your package.json file.

{
  "scripts": {
    "one-folder": "schemata-validator --paths docs",
    "one-file": "schemata-validator --files docs/index.html",
    "all-files": "schemata-validator"
  }
}

Examples

  • schemata-validator: validates all HTML files in the project;
  • schemata-validator --paths docs --exclude build tmp: validates all HTML files in the docs/ folder, except files which have build or tmp anywhere in their pathname or filename;
  • schemata-validator --files docs/index.html: validates only the specified files.

Application code

In addition to the CLI interface, schemata-validator can be imported and called in ESM and TypeScript projects.

import { SchemataValidator } from "schemata-validator";

const jsonld = `{
  "@context": "https://schema.org",
  "@type": "WebPage",
  "name": "Web page title",
  "description": "Web page description"
}`;
const options = { data: [jsonld] };
const validator = new SchemataValidator(options);
const validate = await validator.validate();
validator.log(validate); // Outputs the reporting object
import { SchemataValidator } from "schemata-validator";

const options = { paths: ["docs"] };
const validator = new SchemataValidator(options);
const validate = await validator.validate();
validator.log(validate); // Outputs the reporting object

Get help

Copyright & licence

© 2026 Victor Brito — Released under the MIT licence.

About

Check the validity of Schema.org vocabulary used in JSON-LD and HTML microdata

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Contributors