JSON to Java Class
Convert JSON to a Java POJO class with getters/setters and inferred types. Supports nested classes and arrays as List. Everything in your browser.
Generate the POJO from an endpoint response
The endpoint returned an object with twenty fields and you need the matching class to deserialise with Jackson or Gson. Typing out a field, a getter and a setter for each one is the kind of work where mistakes do not show up at compile time. They show up in production, as a null field nobody can explain. Paste the JSON and get the class back with types inferred and nested objects split into their own classes.
Type inference looks at values, not names. Text becomes String, true or false becomes boolean, a whole number becomes long, a number with a decimal point becomes double, and null becomes Object. An array becomes a List parameterised by the first element's type, using the boxed Long and Double because Java generics reject primitives. A nested object gets its own class named after the key in PascalCase, and an array of objects gets an Item suffix.
The sharp edge: field names come out exactly as they appear in the JSON. A key called first_name becomes a field with an underscore and a getFirst_name method, and a key with a hyphen or a space produces an identifier that will not compile at all. Rename before pasting or after generating. Every class is marked public, so split them into files or drop the modifier on the inner ones. No Jackson annotations, no Lombok, no equals or toString. Runs in the browser.
Frequently asked questions
Why long instead of int?
Does it add Jackson annotations?
Can the JSON root be an array?
Related Tools
JSON to C# Class
Convert JSON to a C# class with auto-implemented properties. Detects primitive types, lists, arrays and nested objects. Useful for .NET/Unity. Everything in your browser.
JSON to TypeScript
Convert a JSON to TypeScript interfaces with automatically inferred types. Detects strings, numbers, booleans, arrays, nested objects and union types. Everything in your browser.
YAML to NDJSON Converter
Explains how to represent YAML lists as NDJSON (one JSON object per line) with practical examples.