JSON to Class Generator

Paste a JSON sample, pick a language and get ready-to-use classes. Nested objects become separate classes.

Input Code
Ready - Type or paste code in the left panel
Output Code
Ready - Type or paste code in the left panel

How to generate classes from JSON

  1. Paste a JSON object into the left panel, or click Load Sample.
  2. Pick the output language on the right: Java, TypeScript, Python, JavaScript or C#.
  3. For Java, choose Lombok or a plain POJO and which constructors you want.
  4. Click Convert, then Copy Output.

What you get

Every JSON object becomes a class, and nested objects get a class of their own, named after their key. The top-level class is called RootObject, so rename it to fit your code. In Java, C# and TypeScript, field types come from the sample values: text becomes String, whole numbers become int, decimals become double, and so on. For example, with Java and Lombok:

{ "userName": "ada", "age": 36, "address": { "city": "London" } }

produces an Address class with a city field, and a RootObject class with userName, age and address, each annotated with @Data and the constructor annotations you picked.

Tips for better results

Is my code sent anywhere?

Yes. The conversion runs on our server: your input is sent, converted in memory and returned. It isn't stored. See the privacy policy for details.

Frequently asked questions

Which languages can I generate?

Java (with Lombok annotations or as a plain POJO), TypeScript, Python, JavaScript and C#.

Why is my top-level class called RootObject?

JSON doesn't name its outermost object, so the generator uses RootObject. Rename it after copying the code.

How are field types chosen?

In Java, C# and TypeScript the types come from the values in your sample: text becomes a string, whole numbers an integer, decimals a double or number, and true/false a boolean. Python and JavaScript classes are generated without type annotations. A field that is null in the sample has no type to go on, so give it a real value before converting.

Does it handle nested objects?

Yes. Every nested object becomes its own class, named after its key, and the parent class gets a field of that type.

Share Content

Choose what to share and generate an instant link

🔥 One-time link Content deleted from server after first view
✉️
Uploading to server…