Java JSON Schema Generator – creating JSON Schema (Draft 6, Draft 7, Draft 2019-09, or Draft 2020-12) from Java classes
570
stars
544
commits
Java
primary language
Jun 23, 2026
updated
Creating JSON Schema (Draft 6, Draft 7, Draft 2019-09 or Draft 2020-12) from your Java classes utilising Jackson.
This project consists of:
jackson annotations (e.g. "description", property name overrides, what properties to ignore) as well as looking up appropriate (annotated) subtypesjakarta.validation.constraints annotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength")javax.validation annotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength")swagger (1.5.x) annotations (e.g. "description", property name overrides, what properties to ignore, their "minimum"/"maximum", "const"/"enum")swagger (2.x) @Schema annotationsAnother example for such a module is:
JavaDoc is being used throughout the codebase, offering contextual information in your respective IDE or being available online through services like javadoc.io.
Additional documentation and configuration examples can be found here: https://victools.github.io/jsonschema-generator
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>5.0.0</version>
</dependency>
Since version 4.7, the release versions of the main generator library and the (standard) victools modules listed above are aligned.
It is recommended to use identical versions for all of them to ensure compatibility.
It is discouraged to use an older/lower jsonschema-generator version than any of your jsonschema-module-* dependencies. If the module uses any feature only added to the jsonschema-generator in the newer version, runtime errors are to be expected.
import com.github.victools.jsonschema.generator.OptionPreset;
import com.github.victools.jsonschema.generator.SchemaGenerator;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfig;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.generator.SchemaVersion;
import tools.jackson.databind.JsonNode;
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);
System.out.println(jsonSchema.toPrettyString());
Additional examples can be found in the jsonschema-examples folder or throughout the various tests classes.
Java
74.2%
JavaScript
23.2%
SCSS
1.7%
Java JSON Schema Generator – creating JSON Schema (Draft 6, Draft 7, Draft 2019-09, or Draft 2020-12) from Java classes
570
stars
544
commits
Java
primary language
Jun 23, 2026
updated
Creating JSON Schema (Draft 6, Draft 7, Draft 2019-09 or Draft 2020-12) from your Java classes utilising Jackson.
This project consists of:
jackson annotations (e.g. "description", property name overrides, what properties to ignore) as well as looking up appropriate (annotated) subtypesjakarta.validation.constraints annotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength")javax.validation annotations (e.g. which properties are nullable or not, their "minimum"/"maximum", "minItems"/"maxItems", "minLength"/"maxLength")swagger (1.5.x) annotations (e.g. "description", property name overrides, what properties to ignore, their "minimum"/"maximum", "const"/"enum")swagger (2.x) @Schema annotationsAnother example for such a module is:
JavaDoc is being used throughout the codebase, offering contextual information in your respective IDE or being available online through services like javadoc.io.
Additional documentation and configuration examples can be found here: https://victools.github.io/jsonschema-generator
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>5.0.0</version>
</dependency>
Since version 4.7, the release versions of the main generator library and the (standard) victools modules listed above are aligned.
It is recommended to use identical versions for all of them to ensure compatibility.
It is discouraged to use an older/lower jsonschema-generator version than any of your jsonschema-module-* dependencies. If the module uses any feature only added to the jsonschema-generator in the newer version, runtime errors are to be expected.
import com.github.victools.jsonschema.generator.OptionPreset;
import com.github.victools.jsonschema.generator.SchemaGenerator;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfig;
import com.github.victools.jsonschema.generator.SchemaGeneratorConfigBuilder;
import com.github.victools.jsonschema.generator.SchemaVersion;
import tools.jackson.databind.JsonNode;
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_2020_12, OptionPreset.PLAIN_JSON);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(YourClass.class);
System.out.println(jsonSchema.toPrettyString());
Additional examples can be found in the jsonschema-examples folder or throughout the various tests classes.
Java
74.2%
JavaScript
23.2%
SCSS
1.7%