Skip to main content

JSON to Java Entity (JPA)

Paste JSON and get Spring Boot JPA entities with @Entity, @Id, @Column and Lombok. jakarta or javax, embedded or separate entities.

Paste JSON on the left. Add a second sample to find optional fields.

JSON input

Stays in your browser

JPA Entity code

The generated code appears here.

Shortcuts: Ctrl+Enter run · Ctrl+Shift+C copy result · / search (use ⌘ on Mac)

Next steps

Free Online JSON to Java Entity (JPA) Generator

Create Spring Boot JPA entity classes from a JSON sample, with the mapping annotations already written. It gives developers a quick browser-based way to solve a focused json to java entity (jpa) task before moving the result into a project.

How to generate JPA Entity code from JSON

Paste a JSON object or an array of objects into the input box and press Generate. The root becomes an @Entity with an @Id and @GeneratedValue. Nested objects become @Embedded types or separate @OneToOne entities, and lists of values use @ElementCollection.

One input, every language

Your JSON stays in the box when you switch the language tabs, and the code is generated again at once. Each language also has its own page, so you can bookmark the one you use.

How types are worked out

  • Whole numbers and numbers with decimals are told apart.
  • Add more samples with Add sample: a key missing from some samples becomes optional, and null makes a type nullable.
  • Arrays of objects are merged into one type, and nested objects become their own types named after the key.
  • Keys that are not valid names in the language (such as first-name or 2fa) are renamed and mapped back, never rejected.

Worked example

The sample JSON in the box above, generated with the default options:

{
  "id": 1,
  "name": "Ada",
  "email": null,
  "tags": ["x"],
  "address": { "city": "Pune", "pin": "411001" },
  "createdAt": "2026-01-15T10:30:00Z"
}
import jakarta.persistence.*;
import java.util.List;
import java.time.OffsetDateTime;
import lombok.Data;

@Data
@Entity
@Table(name = "root")
public class Root {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Long id;

    @Column(name = "name", nullable = false)
    private String name;

    @Column(name = "email")
    private String email;

    @ElementCollection
    private List<String> tags;

    @Embedded
    private Address address;

    @Column(name = "created_at", nullable = false)
    private OffsetDateTime createdAt;
}

@Data
@Embeddable
public class Address {
    @Column(name = "city", nullable = false)
    private String city;

    @Column(name = "pin", nullable = false)
    private String pin;
}

Common mistakes

  • A single sample cannot show which fields are optional. Paste two or three different responses for a realistic result.
  • A value that is always null gives no type information, so it is treated as a nullable string. Change it by hand if it is something else.
  • Numbers are typed from the samples: 1 and 1.0 look the same in JSON, so use a sample with decimals where you need a float.

Frequently asked questions

Jakarta or javax?
Spring Boot 3 and newer use jakarta.persistence. Choose javax for Spring Boot 2 and older projects.
What if my JSON has no id?
An id field (name configurable) is added with @GeneratedValue so the entity is valid. If the JSON has one, it is used.
Is this a finished data model?
It is a starting point. Review column lengths, relations and naming before you create the tables.
Is my JSON uploaded?
No. The types are worked out in your browser. Nothing you paste is sent to a server.
How do I use this json to java entity (jpa) tool?
Use the interactive controls above; processing stays in your browser and the result is intended as a practical starting point for development work.

More Formatters & Parsers

View all Formatters & Parsers tools →