OrbitTest
Dev Tools Mobile Client

Developer Tools

Java Entity (JPA) to JSON Generator

Paste one or more Java / JPA entity classes and get a realistic JSON payload — or TypeScript interfaces — in return. The generator models one-to-one, one-to-many, many-to-one and many-to-many relationships, resolves @MappedSuperclass inheritance, infers believable values from field names and Bean Validation, and cuts circular references safely. Everything runs in your browser — your code is never uploaded.
Need the reverse? Try the JSON → Java POJO Generator.

Java entities
Generated JSON
 
Paste Java entity classes and click Generate.

From a domain model to a JSON contract

When you expose JPA entities over a REST API, the JSON they serialize to is rarely obvious — relationships nest, inherited audit fields hide in a base class, bidirectional links loop, and lazy collections surprise you. This tool reads your actual entity classes and shows the JSON they describe, so you can design DTOs, write fixtures, or stub an endpoint without booting the application.

How the four relationship types map to JSON

  • One-to-One (@OneToOne) — a single nested object, e.g. "photo": { … }.
  • Many-to-One (@ManyToOne) — also a single nested object; in ID Reference mode it collapses to "authorId": 1 (or the @JoinColumn name).
  • One-to-Many (@OneToMany) — an array of objects, e.g. "books": [ … ].
  • Many-to-Many (@ManyToMany) — an array on both sides, e.g. "tags": [ … ].
  • Cycle safety — repeated or too-deep relationships become a minimal { "id": 1 } reference instead of looping forever.

Beyond the basics

  • Inheritance@MappedSuperclass / extends chains are flattened, so inherited id and audit fields appear.
  • Realistic values — field names and @Email, @Size, @Min, @Max, @Positive shape believable sample data.
  • TypeScript output — emit export interface declarations and enum unions to type your frontend against the backend.
  • Records & Lombok — Java records and @Data POJOs work; the parser reads fields, not getters.

Frequently asked questions

Which relationship types are supported?

All four JPA cardinalities: @OneToOne and @ManyToOne render as a single nested object, while @OneToMany and @ManyToMany render as an array of objects. The tool also infers relationships when no annotation is present — any field whose type is another pasted class becomes a nested object, and a List/Set of such a class becomes an array.

Does it understand inheritance and @MappedSuperclass?

Yes. When an entity extends another pasted class — the common BaseEntity / AuditableEntity pattern holding id, createdAt and updatedAt — those inherited fields are merged into the output in declaration order, with child fields overriding parents of the same name. Inheritance chains of any depth are resolved, with cycle protection.

How realistic are the generated values?

Values are inferred from both the Java type and the field name, and refined by Bean Validation annotations. An @Email field becomes "user@example.com", a field named price becomes 99.99, createdAt becomes an ISO timestamp, @Size(min=…) produces a string of the right length, and @Positive / @Min / @Max keep numbers in range. The result reads like a real payload, not a skeleton of zeros and "string".

How are bidirectional relationships and infinite loops handled?

Bidirectional links (a Customer with Orders, where each Order points back to its Customer) would loop forever when serialized. The generator detects cycles and cuts them: once a class already appears in the current ancestry, or the max depth is reached, it emits a minimal ID reference instead of recursing. With "Respect Jackson annotations" on, fields marked @JsonBackReference or @JsonIgnore are omitted, mirroring how Jackson actually serializes the graph.

What is the difference between Nested, ID Reference and TypeScript output?

Nested embeds the full related object (or array of objects) — the default serialization shape. ID Reference produces the flattened DTO style: a @ManyToOne "customer" becomes "customerId" (or the @JoinColumn name), and a @OneToMany "orders" becomes "orderIds": [..]. TypeScript emits export interface declarations for the root entity and every type it reaches, including string-literal unions for enums — ideal for typing a frontend against your backend model.

Is my code sent anywhere?

No. Parsing and generation happen entirely in your browser with JavaScript. Your entity classes never leave your device, so it is safe to use with proprietary domain models.