Code generation

JSON to Java

Generate Java classes from a JSON sample.

JSON input

Settings

Output

Result appears here after you select

{ } How to use

  1. Paste a JSON sample that shows every field you care about.
  2. Set the root class name, and turn on the populated instance if you want sample values as well as the types.
  3. Select Process, then copy the code or download the file.

{ } How it works

JSON to Java works on the text you provide. Adjust the options, then select Process ▸ and it runs entirely in your browser — nothing is uploaded to a server — then shows the result in the Output panel.

Inputs

  • JSON input — paste or type your input in the left panel (use Sample for an example)
  • Root class name — a value (default: "Root")
  • Include a populated instance (from your JSON) — on/off toggle (default: off)

Output

JAVA text — copy or download it from the Output panel.

{ } Common uses

  • Get typed models for an API response without writing them by hand.
  • Bring client types back in step with a payload that has just changed.
  • Turn a saved response into a fixture your tests can construct.

{ } Limitations

  • Types are inferred from the one sample you paste. A field the sample happens not to include is not generated, and nothing is marked optional unless the sample holds a null there — so paste a complete example.
  • An array is typed from its first element only, and an empty array falls back to the untyped element. A nested object becomes its own class, named after the key it sits under; two differently shaped objects under the same key name get a numeric suffix rather than being merged.
  • A public-field class with an all-arguments constructor — no getters, no setters, no Jackson annotations. Arrays use List.of, which needs Java 9 or newer.

{ } FAQ

Is my data uploaded to a server?

No. Everything runs locally in your browser — your files never leave your device.

Can I process more than one file at once?

This tool works on one input at a time.

Is this tool free?

Yes — it’s completely free and needs no sign-up.

Are the types correct for my whole API?

They are correct for the sample you pasted. What the sample does not show — an optional field, a second shape in the same array, a wider number range — cannot be inferred, so treat the output as a first draft to check against the API documentation.

What does the populated instance give me?

A root declaration built from your actual JSON, using the types just generated. It is useful as a test fixture; leave it off when you only want the definitions.