Registry / devops / gulp-json-schema

gulp-json-schema

JSON →
library1.0.0jsnpmunverified

Gulp plugin for validating JSON files against JSON Schema (draft v4) using the tv4 validator. Version 1.0.0 is the latest stable release, with no recent updates. Key differentiators: it integrates seamlessly into Gulp pipelines, supports custom formats and keywords, schema preloading for $ref resolution, and options like banUnknownProperties and checkRecursive. Alternatives include gulp-ajv for newer JSON Schema drafts and better performance.

npm install gulp-json-schema
INSTALL
IMPORT
SIG · GULP-JSON-SCHEMA
G
gulp-json-schema
devopsjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jsonSchema
const jsonSchema = require('gulp-json-schema');
import jsonSchema from 'gulp-json-schema';
CJS-only; not ESM compatible.
jsonSchema (with options in first argument)
jsonSchema({ schema: 'schema.json', verbose: true });
jsonSchema('schema.json', { schema: 'schema.json' });
Options can be passed as first argument with schema property.
tv4 (from internal)
const jsonSchema = require('gulp-json-schema');
const tv4 = require('gulp-json-schema').tv4;
tv4 is not exported; use `configure` option to customize tv4 instance.

Basic Gulp task that validates all JSON files in data/ against schema.json with verbose output and unknown property ban.

const gulp = require('gulp'); const jsonSchema = require('gulp-json-schema'); gulp.task('validate', () => { return gulp.src('data/**/*.json') .pipe(jsonSchema({ schema: 'schema.json', verbose: true, banUnknownProperties: true })); });
Debug
Known issues
gotchaOnly supports JSON Schema draft v4 via tv4; newer drafts (v6, v7, 2019-09, 2020-12) are not supported.
fix
Use gulp-ajv or another plugin that supports newer drafts.
affects: >=1.0.0
gotchaCJS-only; does not provide ESM exports. Node.js ESM users cannot import directly.
fix
Use dynamic import within a CommonJS wrapper or migrate to an ESM-compatible plugin.
affects: >=1.0.0
deprecatedtv4 is unmaintained; no fixes for security or spec updates.
fix
Consider migrating to gulp-ajv (ajv-based) for active support.
affects: >=1.0.0
gotchaRemote schema fetching requires `loadMissingSchemas: true` and request library; may expose to network issues or security concerns.
fix
Preload schemas locally or use offline validation.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: jsonSchema is not a function
Using ESM import syntax (import jsonSchema from 'gulp-json-schema') with a CJS-only module.
fix
Use require('gulp-json-schema') instead.
Error: Invalid schema: [object Object]
Passed a schema object as first argument without using { schema: ... } syntax.
fix
Use jsonSchema({ schema: mySchemaObject }) or jsonSchema('path/to/schema.json').
ValidationError: Data does not match any schemas from 'oneOf'
Schema uses draft v6/v7 features not supported by tv4.
fix
Rewrite schema to be draft v4 compatible or use a different validator.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
tv4requiredJSON Schema validation backend
gulprequiredPeer dependency for plugin integration
Agent activity
6 hits · last 30 days
node
6
Resources
gulp-json-schema — npm install gulp-json-schema · libregistry