Convert Java classes to JSON!

Paste Java DTO/POJO/record code and get an example JSON! Supports Jackson @JsonProperty/@JsonIgnore and Lombok. Handy for API docs and mock request bodies.
Java
Result
 

Convert Java classes to JSON!

Feed it Java DTO, POJO or record source and get the JSON that Spring Boot's default Jackson setup would most likely produce. Keys come from the declared fields, with @JsonProperty, @JsonIgnore, @JsonIgnoreProperties and the static/transient exclusions applied.

Use it to produce a Swagger example or a sample payload for the frontend from a controller's request or response DTO, or simply to check which keys a Lombok @Data class will emit.

How to use

  1. Paste the DTO source as is. Imports, Lombok annotations, constructors and methods can stay.
  2. Include nested static class, record and enum declarations in the same input so referencing fields are filled with their structure.
  3. With Root type set to Auto, the class no other class uses as a field type is chosen. When entities reference each other, pick the one you want from the list.
  4. Copy the output into @Schema(example = ...), a REST Docs snippet or a MockMvc request body.

Example

Input (Java)
@Data
@JsonIgnoreProperties({"password"})
public class MemberResponse {
    private Long memberId;
    @JsonProperty("nick_name")
    private String nickname;
    private String password;
    private Grade grade = Grade.SILVER;
    private LocalDate birthDate;
    private List<Address> addresses;
    private static final long serialVersionUID = 1L;

    public enum Grade { BRONZE, SILVER, GOLD }

    public record Address(String zipCode, String city, boolean primary) {}
}
Output (JSON)
{
  "memberId": 0,
  "nick_name": "",
  "grade": "SILVER",
  "birthDate": "1970-01-01",
  "addresses": [
    {
      "zipCode": "",
      "city": "",
      "primary": false
    }
  ]
}

password is removed by the class-level @JsonIgnoreProperties({"password"}), and the static final serialVersionUID never shows up. The initializer Grade.SILVER is read, so grade is "SILVER" rather than the enum's first constant. The nested record Address expands into an array of objects.

Supported features

  • Field names become keys, overridden by @JsonProperty("x") or @JsonProperty(value = "x").
  • Excluded: @JsonIgnore fields, keys listed in a class-level @JsonIgnoreProperties({...}), and static or transient fields.
  • Supports Java 16+ record components, nested static class declarations and fields inherited via extends (parent fields first).
  • Enum fields hold the first constant as a string, or the constant named in a field initializer; @JsonProperty("x") on a constant changes the string to x.
  • Dates follow Spring Boot's default Jackson output: LocalDateTime → 1970-01-01T00:00:00, LocalDate → 1970-01-01, Instant/OffsetDateTime/ZonedDateTime → ISO string ending in Z, java.util.Date/Timestamp → 1970-01-01T00:00:00.000+00:00.
  • Numeric wrappers such as BigDecimal and Long become 0, Optional<T> unwraps to T, byte[] becomes a Base64 string, and UUID and MongoDB ObjectId get well-formed values.
  • List, Set and arrays get one sample element; a map such as Map<Long, V> with a numeric key uses "0", otherwise "key".

Use cases

Filling springdoc / Swagger examples

Hand-written example values drift every time a field is added to a DTO. Generate the JSON from the DTO source and polish the values from there, so no key is missing or misspelled.

Request bodies for MockMvc or RestAssured tests

Create the request JSON straight from the @RequestBody DTO and paste it into a text block (""") in your test. Keys renamed with @JsonProperty are already applied, matching real binding.

Sharing a response shape with the frontend

Frontend developers who don't read the backend code get the endpoint's JSON structure directly, instead of having to interpret a Java class.

Notes and limitations

  • Field initializers are used when they are a literal (= "guest", = 100, = true) or an enum constant (= Grade.SILVER); anything else, such as new ArrayList<>() or a method call, falls back to the type's placeholder.
  • Getters without a matching field, such as getFullName() or boolean isVip(), are added as properties the way Jackson does, honoring @JsonIgnore/@JsonProperty on that getter. Conversely, a private field without a getter is assumed visible (as with Lombok @Getter/@Data).
  • Global naming rules (@JsonNaming(SnakeCaseStrategy.class), spring.jackson.property-naming-strategy) and @JsonFormat date patterns are not applied.
  • @JsonValue methods on enums are not evaluated, so such enums still show the constant (or its @JsonProperty name).
  • Spring Data Page<T>/Slice<T> fields are simplified to an array of elements; real Page serialization is an object with content, pageable and more.

FAQ

Does it work when Lombok @Data or @Getter generates the accessors?

Yes. Keys are built from declared fields, so getters and setters that Lombok generates at compile time don't need to be in the source.

Why is LocalDateTime a string and not an array of numbers?

Spring Boot registers jackson-datatype-jsr310 and disables WRITE_DATES_AS_TIMESTAMPS by default, which yields ISO strings; the sample follows that default. A bare Jackson ObjectMapper may instead write an array like [1970,1,1,0,0].

Can I paste a JPA entity?

Entities have the same field structure, so they parse fine. Bidirectional associations such as @OneToMany would loop, so they are expanded once and then cut off with null or an empty array. There is also a dedicated Spring Boot JPA → JSON page.

What if @JsonIgnore sits on a setter or on the getter of an existing field?

Annotations on a field declaration always apply, and annotations on a getter apply only when no field of that name exists. @JsonIgnore on a setter, or on the getter of a declared field, is not applied, so move it to the field to see its effect.