Paste Java on the left and click "Convert": we will turn it into JSONPaste Java code

What this tool does

You have a Java record or a classic POJO, and you need a JSON payload that matches it, for a request body, an OpenAPI example, or a test fixture. Paste the class plus a constructor call (or a var order = new Order(...) on Java 10+) and you get back JSON shaped the way Jackson or Gson would serialize it, without you having to instantiate anything.

It reads the types instead of swapping text. A BigDecimal is written as a plain number without the constructor call, OffsetDateTime, LocalDateTime and Instant become ISO 8601 text in an RFC 8259 document, a UUID stays a quoted string in its dashed form, boolean remains a boolean, and List, Set and arrays end up as JSON arrays. A Map<String, V> turns into an object whose keys are the map's keys.

Jackson annotations are honoured: @JsonProperty("x") renames the key, @JsonIgnore removes the field, and @JsonInclude(Include.NON_NULL) suppresses nulls. Nested classes, the typical Address inside an Order, are expanded in place. Paste a whole file with several classes; each top-level instance ends up as its own entry. For the full annotation reference see the jackson-annotations docs.

How to use it

Three steps. Works whether you paste a one-line record or a whole model file.

1

Paste your Java (or try the sample)

Paste the class and a constructor call into the left editor; the constructor arguments supply the values. POJOs, records, Lombok @Data classes and static nested classes are all fair game. Load Sample loads an Order with a @JsonProperty("order_id") rename, BigDecimal prices and an OffsetDateTime.

You do not need to delete package declarations, imports, or public/private modifiers. Leave the standard Java syntax as-is. Jackson annotations, validation annotations, and Lombok decorations are all accepted.

2

Hit Convert

Press the green Convert button. Your classes go to the backend, which lines the constructor arguments up with the fields, applies Jackson renames and ignores, and returns JSON while a "Converting..." overlay is shown.

3

Copy the JSON

The right panel shows JSON ready for a Spring Boot request, a JUnit fixture, or a Swagger example. Copy it wherever you need.

When this actually comes in handy

Spring Boot request samples

Paste a <code>@RequestBody</code> DTO and a constructor call to get a JSON body you can fire at Postman, curl, or HTTPie without booting the app.

JUnit test fixtures

Convert an object you build in a unit test into a standalone JSON file for integration tests, WireMock stubs, or Testcontainers seed data.

OpenAPI / Swagger examples

Use an actual model class to produce the <code>example</code> block for your OpenAPI spec, so the example stays in sync with the real POJO.

Kafka and messaging payloads

Turn a record representing a Kafka message into JSON for producer testing, sample data, or documentation.

Common questions

Does it respect Jackson annotations?

Yes. @JsonProperty renames fields, @JsonIgnore removes them, @JsonInclude(Include.NON_NULL) suppresses nulls, and @JsonFormat controls date formatting. See the jackson-annotations reference for the full list.

How are BigDecimal, LocalDateTime, and UUID handled?

BigDecimal comes out as a number. LocalDateTime, OffsetDateTime and Instant come out as ISO 8601 strings and LocalDate as "2026-03-14". A UUID keeps its usual quoted, dashed form. That lines up with Jackson once JavaTimeModule is registered and dates are written as text rather than timestamps.

Does it handle records and sealed types?

Yes. Java 14+ record types serialize using their canonical components. Sealed types and their permitted subtypes are flattened to the underlying data shape. See the OpenJDK records JEP for background.

What about Lombok @Data / @Builder classes?

Lombok annotations are recognized: generated getters, setters, and builders are treated as normal accessors. The tool looks at the declared fields plus any constructor call you paste to build the JSON.

Can I paste a whole file with several classes?

Yes. Each top-level class that gets an instance in your paste shows up as a separate entry, and static nested classes such as Order.OrderItem are expanded where they are used.

Is my code stored?

Whatever you paste is handed to the backend for this one conversion and then discarded, not stored. Spring @Value defaults and test constants sometimes hold real credentials, so check before pasting.

Other tools you may need

Going the other way to a Java class, generating TypeScript for the frontend, or checking the JSON itself, these pages cover it: