A CLI and library for generating JSON Schema (draft-v4) from JSON documents. Version 2.0.6 is the latest stable release. It supports local files, URLs, and stdin input with options for pretty-printing and directory output. Note: full draft-v4 spec not yet supported; lacks $ref and location nodes. Alternative to tools like jsonschema or online generators. Low release cadence; GitHub last updated several years ago.
npm install json-schema-generatorNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates generating a JSON Schema from a JavaScript object and saving to file.
Use a newer generator like @jsonschema/json-schema-generator or use a migration tool.
Manually refactor large schemas or use a tool that supports refs.
Ensure input object has at least one property if non-empty schema is desired.
Use const jsonSchemaGenerator = require('json-schema-generator');Wrap path in quotes: json-schema-generator "path/with spaces/input.json"
Create the directory first: mkdir -p schemas && json-schema-generator input.json -o schemas/
No dependency data recorded yet.