Sketch a JSON Schema from Java fields
- Paste a basic Java class or record declaration.
- Generate the JSON Schema draft 2020-12 output.
- Review property types and resolve custom-type references before using the schema.
Worked example
A Java record with String name and int age produces schema properties with string and integer types. Review required fields separately against your API’s actual contract.
Input and output
Start with one simple class or record declaration. Read the generated properties alongside the Java source and validate a representative JSON document with your own schema validator. A date-like Java type may be represented as a string without encoding every rule your application applies to dates.
Format and size limits
Only declarations recognized by the parser contribute fields. A custom type may become a reference whose definition you must supply. Read the required list carefully for records, especially when a component is Optional or when your serializer omits null values.
If processing fails
If an expected property is missing, check whether it comes from a superclass, a getter or a serialization annotation. Compare the schema with an actual serialized instance. Add the missing properties and definitions before relying on validation in your project.
Questions about this tool
Are validation annotations and inheritance included?
No. This is a lightweight parser, not a Java compiler. Advanced generics, inherited fields and annotation-driven validation need manual review.
What happens to custom Java types?
Unknown custom types become references. Supply their schemas or adjust those references before using the output for validation.
How it works
Handles common Java primitives, arrays, List, Set, Optional and records. Unknown custom types are expressed as references.
Important limitations
This is not a Java compiler: inheritance, annotation-based constraints and sophisticated generics are not supported. Custom types become references without generated definitions. Every parsed record component is marked required, including Optional; class fields are not marked required. Review the schema before use.
