JSON to Types
Generate types, serializers, validation schemas and Mermaid diagrams from a JSON sample.
On your device. Your input is not uploaded or saved.
How to generate TypeScript types from JSON
- Paste a JSON sample, such as an API response, or press Load example.
- Under Generate, choose TypeScript, Python · Pydantic v2, Python · DRF serializer, Go, C# · System.Text.Json, JSON Schema · 2020-12, Zod · v4 or Mermaid · Class diagram.
- Enter a Root type name, such as User or ApiResponse.
- Copy the generated code into your project, then review names and constraints that a sample cannot show.
How types are inferred
The generator reads every value in the sample, including every entry of every array. Objects in the same array are merged into one type, fields missing from some entries become optional, and a field that is sometimes null becomes nullable, such as string | null in TypeScript. Whole numbers and decimals are told apart where the language has separate types, such as int and float in Python or int64 and float64 in Go.
A sample cannot show everything. Dates, UUIDs and URLs stay plain strings, and a field present in every entry is treated as required even if your API sometimes leaves it out. A sample with varied entries gives more accurate types.
Supported languages and libraries
TypeScript interfaces; Pydantic v2 models for Python 3.10+; standalone Django REST framework serializers; Go 1.18+ structs with encoding/json tags; C# 12 classes for .NET 8+ with System.Text.Json; JSON Schema Draft 2020-12 with local $defs; Zod 4 schemas with an inferred TypeScript type; and Mermaid class-diagram source for documentation.
Keys that are not valid names in the target language, such as user-id, keep their original JSON key through Field(alias=...) in Pydantic, json tags in Go and [JsonPropertyName] in C#.
Limits
Strict JSON only, up to 100,000 characters, 10,000 values, 40 nesting levels and 200 object shapes. Integers outside JavaScript's safe range are rejected, so write large IDs as strings. To fix invalid JSON or convert a Python dictionary first, use the JSON Formatter.
Where does my data go?
Types are generated in your browser. The tool never uploads or saves your sample, so you can use a real API response.
Like the rest of the site, this page uses Google Analytics and Yandex Metrica, including Metrica session replay. Tool events report only that the tool was opened or used.
The tool area is marked so that Metrica masks what you type and the results in its session recordings.
Also useful
No third-party trackers on JZR Tools. We count anonymous visits with country, referring site and device type only.