JSON to Java Converter

Paste JSON and get Java classes (POJOs) with fields, getters and setters.

Add JSON and click Generate to see the code here.

How JSON to Java Converter works

Generates Java classes (POJOs) from a JSON sample. Each JSON object becomes a class with private fields, getters and setters. Nested objects get their own class, named after their key.

For an array of objects, all items are merged into one class, so keys that only some items have are included too. Type the class name you want in the Name box. Default is RootObject.

Input to JSON to Java Converter

  • Paste or type JSON into the input box, or upload a .json or .txt file. Then click Generate.
  • Use real sample data. Types are read from the values, so 42 gives long, 4.2 gives double and "text" gives String.
  • Input must be valid JSON. If something is wrong, you see the line and column of the first error.

Output from JSON to Java Converter

  • Java code with one class for each object shape. Field names are camelCase, and boolean getters start with is.
  • Values that can be null or missing use Long, Double and Boolean instead of long, double and boolean. Arrays become List, and null or mixed values become Object.
  • When a field name differs from the JSON key, a Jackson @JsonProperty annotation keeps the original key.
  • Copy it, download it as a .java file named after the main class, like RootObject.java, or open it in full screen.