eslint-plugin-json-schema-validator

raw JSON →
6.2.0 verified Sat Apr 25 auth: no javascript

ESLint plugin that validates JSON, JSONC, JSON5, YAML, TOML, JavaScript, and Vue custom blocks against JSON Schema. Current stable version is 6.2.0 (released 2025-06-10). Requires ESLint >=9.38.0 and Node.js >=20.19.0 (20.x), >=22.13.0 (22.x), or >=24. Actively maintained with monthly releases. Key differentiator: validates structured data formats using JSON Schema within ESLint flat config, supporting multiple data languages and schema from SchemaStore.

error Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/eslint-plugin-json-schema-validator/dist/index.js from /path/to/eslint.config.js not supported.
cause v6.0.0 is ESM-only, but eslint.config.js is being loaded via CommonJS (require).
fix
Rename eslint.config.js to eslint.config.mjs or add 'type': 'module' to package.json.
error Error: Failed to load plugin 'json-schema-validator' declared in 'plugins': Cannot find module 'eslint-plugin-json-schema-validator'
cause Plugin is not installed or ESLint version <9.38.0 incompatibility with v6.
fix
Install or update: npm install eslint-plugin-json-schema-validator@latest --save-dev; ensure ESLint >=9.38.0.
error Configuration for rule 'json-schema-validator/no-invalid' is invalid: Value 'warn' is not a valid severity level.
cause Severity must be 0, 1, 2, 'off', 'warn', or 'error'.
fix
Use 'warn' (string) or 1 (number) correctly: 'json-schema-validator/no-invalid': 'warn' (with quotes).
breaking ESLint plugin requires ESLint >=9.38.0 and Node.js >=20.19.0/22.13.0/>=24.0.0
fix Update ESLint: npm install eslint@^9.38.0 --save-dev; ensure Node.js >=20.19.0 (20.x) or >=22.13.0 (22.x) or >=24.0.0.
breaking v6.0.0 dropped support for older ESLint versions; requires flat config only (eslint.config.js).
fix Migrate from .eslintrc to eslint.config.js using flat config format.
breaking v6.0.0 replaced require() with ESM imports; CommonJS require() will fail.
fix Convert all require('eslint-plugin-json-schema-validator') to import statements. Ensure package.json has 'type': 'module' or use .mjs extension.
gotcha Plugin does not validate .js files by default; only JSON, YAML, TOML, and Vue SFC.
fix If you need to validate JSON Schema in JS files, ensure they are processed by ESLint with appropriate parser settings (e.g., @babel/eslint-parser).
deprecated The flat/ prefix in configs (e.g., configs['flat/recommended']) is deprecated in v6.
fix Use configs.recommended directly instead of configs['flat/recommended'].
gotcha SchemaStore URLs are normalized to www.schemastore.org; custom URLs may not be recognized.
fix Ensure custom schema URLs are valid and not blocked by normalization. Use local schema files if normalization causes issues.
npm install eslint-plugin-json-schema-validator
yarn add eslint-plugin-json-schema-validator
pnpm add eslint-plugin-json-schema-validator

ESLint flat config using recommended configuration; validates JSON, YAML, and TOML against JSON Schema.

// eslint.config.js
import eslintPluginJsonSchemaValidator from 'eslint-plugin-json-schema-validator';
export default [
  ...eslintPluginJsonSchemaValidator.configs.recommended,
  {
    rules: {
      'json-schema-validator/no-invalid': 'warn'
    }
  }
];
// Run: npx eslint --ext .json,.yaml,.toml src/