JSON to Java
Generate Java POJOs, records or Lombok classes from JSON
Paste JSON or load an example to generate Java code.
What JSON to Java generates
JSON to Java turns an API response or any JSON sample into Java model types. POJO mode writes private fields with getters and setters, Lombok mode adds @Data, @NoArgsConstructor and @AllArgsConstructor, and Record mode writes Java 16+ records. Jackson and Gson are separate choices because a model normally uses one of them; the matching annotation is added only where a field name differs from its JSON key.
How to use
- 1.Paste JSON, upload or drop a .json file, or load one of the examples.
- 2.Set the root class name and an optional package such as com.example.model; a blank package omits the package line.
- 3.Pick the model style and the JSON library.
- 4.Read the notes under the output, then copy the code or download <Root>.java.
How types are inferred
- •Every array item is inspected, not just the first one, and objects in the same array are merged.
- •A key missing from some objects is optional; a key that is sometimes null is nullable. The two are kept apart.
- •1 and 2.5 in the same position widen to a decimal number; other mixes are reported.
- •Empty arrays and values that are only ever null have no type evidence, so a generic type is used and a note explains why.
- •Type mapping: string → String, integer → Integer, Long or BigInteger by range, decimal → Double, boolean → Boolean, array → List<T>, object → nested static class, unknown or mixed → Object.
- •Reserved words such as class or package get a trailing underscore and keep the original key in the annotation.
Limits and privacy
A sample shows what the data looked like once, not the full API contract. Review optional fields, generic types and number widths before relying on the code. Input is limited to 5 MB and 256 nesting levels; from 2 MB, generation waits for the Generate button. Everything runs in your browser and the JSON is never uploaded. Without Jackson or Gson, renamed keys are not mapped automatically, and the notes list each one.
