JSON to TypeScript, Zod, Pydantic, Go and Java
Generate TypeScript, Zod, Pydantic, Java, C#, Go or JSON Schema from a JSON sample. Handles nested types and optional fields, and runs locally in your browser.
JSON to Code tool
Runs entirely in your browser. Nothing you paste is uploaded or stored.
Types are inferred from your sample only. Check optional fields and number types against the real API contract.
Found a problem or have an idea for this tool? Send feedback.
About this tool
Paste a JSON sample and get TypeScript interfaces, Zod schemas, Pydantic models, Java records, C# records, Go structs or a JSON Schema. Nested objects become their own types, arrays of objects are merged so fields missing from some elements become optional, and snake_case keys are mapped with the right JSON annotation.
Types come from your sample only, so check them against the real API contract. Fields that were only ever null are flagged because their type can't be known.
How to use it
- Paste a JSON sample and choose a language.
- Set the root type name.
- Copy or download the generated code.
Limitations
- Types reflect the sample, not a schema.
- Dates are left as strings.
Example
{"orderId":1001,"customer_name":"Ann","items":[{"sku":"A","qty":2}]}import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public record Order(
Integer orderId,
@JsonProperty("customer_name") String customerName,
List<Item> items
) {}
public record Item(
String sku,
Integer qty
) {}
Common use cases
Consuming a new API
Create the response classes from a sample instead of typing them.
Test fixtures
Get typed models for the payloads in your tests.
Documentation
Show the shape of a payload as types in a pull request.