JSON to Java Class
Turn a JSON object into Java classes with private fields, getters and setters. Nested objects become static inner classes and arrays become List types.
1 Paste your text and pick the options
2 Your answer
Your answer shows here as you type.
How to use the JSON to Java Class
- Paste a JSON object, or an array of objects, into the JSON box.
- Set the name for the root Java class, such as User or Order.
- Turn getters and setters on or off, then copy the Java code from the output.
Frequently asked questions
Which Java types are used for JSON values?
Strings become String, true and false become boolean, and whole numbers become int when they fit in 32 bits or long when they do not. Numbers with decimals become double, arrays become List types, and null becomes Object.
How are nested JSON objects handled?
Each nested object becomes a public static inner class inside the root class, so the whole output fits in one Java file. Arrays of objects are merged into one class for their items.
Why are some field names different from the JSON keys?
Java names cannot contain dashes or spaces, and they usually use camelCase. Keys such as first-name become firstName, so a JSON library may need a rename annotation to map them back.
Does the generated code need a JSON library?
No. The output is plain Java with private fields and optional getters and setters. A library such as Jackson or Gson can fill it in directly when the field names match the JSON keys.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.