jsontoolskit.org
JSON and JSON Schema utilities, in the browser
Say hi →

JSON to Java

JSON sample → records or POJOs · updated 28 July 2026

Generate Java types from a JSON sample. Pick modern record declarations or classic POJOs with getters and setters. Keys that are not valid camelCase Java names get a @JsonProperty annotation so Jackson still binds them.

Paste input to start.

How to generate Java classes from JSON

  1. Paste a JSON sample — ideally an array of several records, so optional fields are detected.
  2. Set the Root type name. Nested objects are named after the key that holds them, singularised for arrays.
  3. Choose record for immutable data carriers, or class if you need a mutable bean — some frameworks still require a no-arg constructor and setters.
  4. Set a Package to get the declaration at the top of the file.
  5. Copy the code, or download it as a file.

Type mapping

Nested types are emitted as public static members of the root type, so the whole model fits in one file. Split them out if you prefer one type per file.

Getting good types out of a sample

Type inference from a sample is only as good as the sample. Three habits make the output far more useful:

Privacy

Nothing is uploaded. Inference and code generation run in this tab. No server sees the payload you paste — which matters, because real API responses tend to contain real user data.

FAQ

Records or classes?

Records for anything you deserialise and read — less code, immutable, correct equals and hashCode for free. Jackson supports them natively since 2.12. Classes if a framework needs bean semantics, or you target Java 11 or older.

Which Jackson version do the annotations need?

@JsonProperty has been in com.fasterxml.jackson.annotation since Jackson 2.0. For records, use 2.12 or later so the canonical constructor is discovered without extra configuration.

What about BigDecimal for money?

Nothing in a JSON sample distinguishes a price from any other number, so you get double. Change money fields to BigDecimal by hand — floating point and currency do not mix.