JSON to Java
Paste a JSON response and get Java records or classic POJOs with getters and setters. Fields the payload can omit or send as null come back boxed, because a Java primitive has no way to represent absence.
Output appears here as you type.
Runs entirely in your browser. Nothing you paste here is uploaded or stored.
Questions
Is my JSON uploaded anywhere?
No. Inference and code generation run entirely in your browser. Nothing is sent to a server, so pasting a real API response with customer data or internal URLs is safe.
Should I paste one object or an array of them?
An array, whenever you have one. Every element is merged into a single shape, so a field that is missing from some records becomes optional and a field that is sometimes null becomes nullable. One object can only ever tell the generator that everything is required.
Why does this produce different types than other converters?
Because every element of the array is merged before anything is generated. A converter that reads only the first record cannot know that a field is missing from later ones, or that it is sometimes null, so it emits a plain non-nullable type. In a statically typed language that is not a cosmetic difference: it is the line between a clean decode and a nil dereference at runtime.
Why is one field long and another Long?
A primitive long cannot be null. If the API omits a field or sends null, a long silently stays 0 and your code cannot tell that apart from a zero the server really sent - so any field the sample showed as absent or null is boxed. Fields present in every record stay primitive, which is faster and clearer about intent.
Records or POJOs?
Records if you are on Java 16 or later and the data is immutable, which is usually true of a decoded response - they are a fraction of the code. POJOs if a framework requires a no-arg constructor and setters, which some older Jackson and JPA setups still do.
Why is each class shown as a separate file?
Java allows only one public top-level type per file, so concatenating them would not compile. Each block is headed with the filename it belongs in.
More code generation tools
JSON → TypeScript
Generate named interfaces, with optionals and nullability inferred from every sample.
JSON → Zod
Generate a Zod schema, with formats, enums and optionals already applied.
JSON → JSON Schema
Generate a draft 2020-12 or draft-07 schema with $defs and required arrays.
JSON → Go
Generate Go structs with json tags, pointers for optional fields, and gofmt spacing.
JSON → C#
Generate C# classes or records with nullable annotations and serializer attributes.
JSON → Python
Generate Pydantic models or dataclasses, with aliases and correct field ordering.
JSON → Rust
Generate serde structs with Option, rename attributes and rustfmt spacing.