This is a command-line tool that generates JSON Schema from JSON data. It's built in Rust and provides a simple way to create JSON Schema definitions from existing JSON structures.
- Generate JSON Schema from JSON files or stdin
- Support for all JSON data types (object, array, string, number, boolean, null)
- Automatic detection of required fields
- Handling of mixed-type arrays
- Output to file or stdout
To install the JSON Schema Generator, you need to have Rust and Cargo installed on your system. Then, you can clone this repository and build the project:
cargo install json_schema_generator
json_schema_generator test.json
git clone https://github.com/AtlasPilotPuppy/json-schema-generator.git
cd json-schema-generator
cargo build --release
The compiled binary will be available in target/release/json_schema_generator
.
json_schema_generator [OPTIONS] [INPUT_FILE]
-o, --output <FILE>
: Specify the output file. If not provided, output will be written to<INPUT_FILE>.jsonschema
or stdout if reading from stdin.-s, --stdout
: Force output to stdout, even when an input file is provided.-h, --help
: Print help information.
-
Generate schema from a file:
json_schema_generator input.json
-
Generate schema from a file and save to a specific output file:
json_schema_generator input.json -o output_schema.json
-
Generate schema from stdin:
cat input.json | json_schema_generator
-
Generate schema from a file and output to stdout:
json_schema_generator input.json --stdout
This tool generates JSON Schema compatible with draft-07.
- The tool generates a basic schema and may not capture all possible constraints or patterns in your data.
- The schema for arrays assumes all items in the array follow the same schema.
Contributions are welcome! Please feel free to submit a Pull Request.