/tools/json-to-java

JSON to Java Converter

Generate one compilable Java 17 root file containing nested records or POJO classes.

Options

JSON sample

Java output

Ready. Paste representative JSON to infer Java types locally.

Generate Java records or POJOs for Jackson

Set the root type to Account, keep Jackson-ready output and generate from:

{"user_id":7,"roles":["reader"]}

The Java 17 record has a long userId component and List<String> roles. The @JsonProperty("user_id") annotation retains the input key. Include Jackson in the target project when using ObjectMapper.readValue(source, Account.class).

Select POJO classes in the declaration options for a project that needs classes. A sample establishes observed types, so include missing, null and varied values before reviewing the generated model.

/usage

Generate Java records or POJOs from JSON

  1. Paste representative JSON or choose a local file.
  2. Select records or classes and Jackson-ready or framework-neutral output.
  3. Generate one root file, review uncertain types, then copy or download it.

Preserve an API key in a Java record

Generate from {"user-id":42} with Jackson output. The generated userId component uses @JsonProperty("user-id") to retain the original JSON key. Review the output for the target project and Jackson dependency.

/output

Serializer-aware Java without shape loss

Compilable root file

Nested declarations live inside one root type, avoiding a spray of partially named files.

Jackson aliases

@JsonProperty preserves JSON keys when safe Java identifiers differ.

Nullable evidence

Missing or null numeric and boolean values use boxed primitives. Arrays become List<T>.

Honest mixed types

Irreducible mixed evidence becomes Object with a visible warning instead of a misleading narrow type.

/faq

JSON to Java questions

Which Java version is targeted?

Java 17 is the default baseline. Select POJO classes where records are not suitable.

Does the converter upload API responses?

No. Parsing, shape inference and Java emission run inside a local browser worker.

What happens with a scalar or array root?

The generator preserves the original root shape through a root deserialisation type and nested item declarations.